Skip to content

Commit 2c41ea0

Browse files
Merge branch 'master' into nijeeshjoshy/cha-3071-compress-webhook-payloads
2 parents 28d8015 + 7640db7 commit 2c41ea0

4 files changed

Lines changed: 74 additions & 7 deletions

File tree

stream_chat/tests/async_chat/conftest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ async def client():
4444
timeout=10,
4545
**options,
4646
) as stream_client:
47+
# Reset the shared CI test app to a permissive upload + command
48+
# config so tests aren't held hostage to whatever a prior PR left
49+
# behind. Empty allow/block lists on every gate (extensions AND MIME
50+
# types) means 'no restrictions' per backend FileUploadConfig.Validate
51+
# in controllers/types.go. Re-registering the default messaging
52+
# channel-type commands keeps /giphy parseable for run_message_action.
53+
permissive = {
54+
"allowed_file_extensions": [],
55+
"blocked_file_extensions": [],
56+
"allowed_mime_types": [],
57+
"blocked_mime_types": [],
58+
}
59+
try:
60+
await stream_client.update_app_settings(
61+
file_upload_config=permissive,
62+
image_upload_config=permissive,
63+
)
64+
except Exception:
65+
pass
66+
try:
67+
await stream_client.update_channel_type(
68+
"messaging",
69+
commands=["giphy", "imgur", "flag", "ban", "mute", "unban", "unmute"],
70+
)
71+
except Exception:
72+
pass
4773
yield stream_client
4874

4975

stream_chat/tests/async_chat/test_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async def test_delete_users(self, client: StreamChatAsync, random_user: Dict):
174174
)
175175
assert "task_id" in response
176176

177-
for _ in range(60):
177+
for _ in range(300):
178178
response = await client.get_task(response["task_id"])
179179
if response["status"] == "completed" and response["result"][
180180
random_user["id"]
@@ -669,7 +669,9 @@ async def test_create_blocklist(self, client: StreamChatAsync):
669669

670670
async def test_list_blocklists(self, client: StreamChatAsync):
671671
response = await client.list_blocklists()
672-
assert len(response["blocklists"]) == 3
672+
# Don't pin the exact count: the shared test app accumulates blocklists
673+
# across CI runs where teardown didn't get to run.
674+
assert len(response["blocklists"]) >= 3
673675
blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]}
674676
assert "Foo" in blocklist_names
675677

@@ -811,7 +813,7 @@ async def test_delete_channels(self, client: StreamChatAsync, channel: Channel):
811813
response = await client.delete_channels([channel.cid])
812814
assert "task_id" in response
813815

814-
for _ in range(60):
816+
for _ in range(300):
815817
response = await client.get_task(response["task_id"])
816818
if response["status"] == "completed" and response["result"][
817819
channel.cid

stream_chat/tests/conftest.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,53 @@ def pytest_configure(config):
2525
config.addinivalue_line("markers", "incremental: mark test incremental")
2626

2727

28+
def _baseline_app_config(stream_client: StreamChat) -> None:
29+
"""Reset the shared CI test app to a permissive upload + command config.
30+
31+
Pinning state here is safer than skip-on-error guards inside individual
32+
tests — those silently mask drift. Empty allow/block lists on every gate
33+
(extensions AND MIME types) means 'no restrictions' per backend
34+
``FileUploadConfig.Validate`` in ``controllers/types.go``. Re-registering
35+
the default ``messaging`` channel-type commands keeps ``/giphy``
36+
parseable for ``run_message_action``.
37+
38+
Best-effort: a test app that doesn't expose either endpoint falls
39+
through and the individual tests surface the real failure.
40+
"""
41+
permissive = {
42+
"allowed_file_extensions": [],
43+
"blocked_file_extensions": [],
44+
"allowed_mime_types": [],
45+
"blocked_mime_types": [],
46+
}
47+
try:
48+
stream_client.update_app_settings(
49+
file_upload_config=permissive,
50+
image_upload_config=permissive,
51+
)
52+
except Exception:
53+
pass
54+
try:
55+
stream_client.update_channel_type(
56+
"messaging",
57+
commands=["giphy", "imgur", "flag", "ban", "mute", "unban", "unmute"],
58+
)
59+
except Exception:
60+
pass
61+
62+
2863
@pytest.fixture(scope="module")
2964
def client():
3065
base_url = os.environ.get("STREAM_HOST")
3166
options = {"base_url": base_url} if base_url else {}
32-
return StreamChat(
67+
stream_client = StreamChat(
3368
api_key=os.environ["STREAM_KEY"],
3469
api_secret=os.environ["STREAM_SECRET"],
3570
timeout=10,
3671
**options,
3772
)
73+
_baseline_app_config(stream_client)
74+
return stream_client
3875

3976

4077
@pytest.fixture(scope="function")

stream_chat/tests/test_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def test_delete_users(self, client: StreamChat, random_user: Dict):
229229
)
230230
assert "task_id" in response
231231

232-
for _ in range(60):
232+
for _ in range(300):
233233
response = client.get_task(response["task_id"])
234234
if response["status"] == "completed" and response["result"][
235235
random_user["id"]
@@ -689,7 +689,9 @@ def test_create_blocklist(self, client: StreamChat):
689689

690690
def test_list_blocklists(self, client: StreamChat):
691691
response = client.list_blocklists()
692-
assert len(response["blocklists"]) == 3
692+
# Don't pin the exact count: the shared test app accumulates blocklists
693+
# across CI runs where teardown didn't get to run.
694+
assert len(response["blocklists"]) >= 3
693695
blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]}
694696
assert "Foo" in blocklist_names
695697

@@ -829,7 +831,7 @@ def test_delete_channels(self, client: StreamChat, channel: Channel):
829831
response = client.delete_channels([channel.cid])
830832
assert "task_id" in response
831833

832-
for _ in range(60):
834+
for _ in range(300):
833835
response = client.get_task(response["task_id"])
834836
if response["status"] == "completed" and response["result"][
835837
channel.cid

0 commit comments

Comments
 (0)