Skip to content

Commit a01d6c4

Browse files
author
Rafael Marinho
committed
revert
1 parent a5c76fd commit a01d6c4

File tree

4 files changed

+26
-200
lines changed

4 files changed

+26
-200
lines changed

stream_chat/tests/async_chat/conftest.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,3 @@ async def hard_delete_users(client: StreamChatAsync, user_ids: List[str]):
141141
)
142142
except Exception:
143143
pass
144-
145-
146-
async def cleanup_blocklists_async(client: StreamChatAsync):
147-
"""Clean up test blocklists"""
148-
try:
149-
# Delete common test blocklist names
150-
test_blocklists = ["Foo", "TestBlocklist", "TestBlocklistAsync"]
151-
for blocklist_name in test_blocklists:
152-
try:
153-
await client.delete_blocklist(blocklist_name)
154-
except Exception:
155-
pass # Blocklist might not exist
156-
except Exception:
157-
pass
158-
159-
160-
@pytest.fixture(autouse=True, scope="session")
161-
async def cleanup_test_data():
162-
"""Global cleanup for test data"""
163-
yield
164-
# This runs after all tests complete
165-
# Add any global cleanup here if needed

stream_chat/tests/async_chat/test_client.py

Lines changed: 13 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
from stream_chat.async_chat import StreamChatAsync
1616
from stream_chat.async_chat.channel import Channel
1717
from stream_chat.base.exceptions import StreamAPIException
18-
from stream_chat.tests.async_chat.conftest import (
19-
cleanup_blocklists_async,
20-
hard_delete_users,
21-
)
18+
from stream_chat.tests.async_chat.conftest import hard_delete_users
2219
from stream_chat.tests.utils import wait_for_async
2320

2421

@@ -725,89 +722,26 @@ async def test_query_channels_members_in(
725722
assert len(response["channels"][0]["members"]) == 9
726723

727724
async def test_create_blocklist(self, client: StreamChatAsync):
728-
blocklist_name = f"TestBlocklistAsync_{uuid.uuid4().hex[:8]}"
729-
await client.create_blocklist(
730-
name=blocklist_name, words=["fudge", "heck"], type="word"
731-
)
732-
733-
# Clean up after test
734-
try:
735-
await client.delete_blocklist(blocklist_name)
736-
except Exception:
737-
pass
725+
await client.create_blocklist(name="Foo", words=["fudge", "heck"], type="word")
738726

739727
async def test_list_blocklists(self, client: StreamChatAsync):
740-
# First, clean up any existing test blocklists
741-
await cleanup_blocklists_async(client)
742-
743-
# Create a test blocklist
744-
blocklist_name = f"TestBlocklistAsync_{uuid.uuid4().hex[:8]}"
745-
await client.create_blocklist(
746-
name=blocklist_name, words=["fudge", "heck"], type="word"
747-
)
748-
749-
try:
750-
response = await client.list_blocklists()
751-
# Should have at least 1 blocklist (the one we just created)
752-
assert len(response["blocklists"]) >= 1
753-
blocklist_names = {
754-
blocklist["name"] for blocklist in response["blocklists"]
755-
}
756-
assert blocklist_name in blocklist_names
757-
finally:
758-
# Clean up
759-
try:
760-
await client.delete_blocklist(blocklist_name)
761-
except Exception:
762-
pass
728+
response = await client.list_blocklists()
729+
assert len(response["blocklists"]) == 2
730+
blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]}
731+
assert "Foo" in blocklist_names
763732

764733
async def test_get_blocklist(self, client: StreamChatAsync):
765-
blocklist_name = f"TestBlocklistAsync_{uuid.uuid4().hex[:8]}"
766-
await client.create_blocklist(
767-
name=blocklist_name, words=["fudge", "heck"], type="word"
768-
)
769-
770-
try:
771-
response = await client.get_blocklist(blocklist_name)
772-
assert response["blocklist"]["name"] == blocklist_name
773-
assert response["blocklist"]["words"] == ["fudge", "heck"]
774-
finally:
775-
# Clean up
776-
try:
777-
await client.delete_blocklist(blocklist_name)
778-
except Exception:
779-
pass
734+
response = await client.get_blocklist("Foo")
735+
assert response["blocklist"]["name"] == "Foo"
736+
assert response["blocklist"]["words"] == ["fudge", "heck"]
780737

781738
async def test_update_blocklist(self, client: StreamChatAsync):
782-
blocklist_name = f"TestBlocklistAsync_{uuid.uuid4().hex[:8]}"
783-
await client.create_blocklist(
784-
name=blocklist_name, words=["fudge", "heck"], type="word"
785-
)
786-
787-
try:
788-
await client.update_blocklist(blocklist_name, words=["dang"])
789-
response = await client.get_blocklist(blocklist_name)
790-
assert response["blocklist"]["words"] == ["dang"]
791-
finally:
792-
# Clean up
793-
try:
794-
await client.delete_blocklist(blocklist_name)
795-
except Exception:
796-
pass
739+
await client.update_blocklist("Foo", words=["dang"])
740+
response = await client.get_blocklist("Foo")
741+
assert response["blocklist"]["words"] == ["dang"]
797742

798743
async def test_delete_blocklist(self, client: StreamChatAsync):
799-
blocklist_name = f"TestBlocklistAsync_{uuid.uuid4().hex[:8]}"
800-
await client.create_blocklist(
801-
name=blocklist_name, words=["fudge", "heck"], type="word"
802-
)
803-
await client.delete_blocklist(blocklist_name)
804-
805-
# Verify it's deleted
806-
try:
807-
await client.get_blocklist(blocklist_name)
808-
pytest.fail("Blocklist should have been deleted")
809-
except Exception:
810-
pass # Expected - blocklist should not exist
744+
await client.delete_blocklist("Foo")
811745

812746
async def test_check_push(
813747
self, client: StreamChatAsync, channel: Channel, random_user: Dict

stream_chat/tests/conftest.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,3 @@ def hard_delete_users(client: StreamChat, user_ids: List[str]):
131131
client.delete_users(user_ids, "hard", conversations="hard", messages="hard")
132132
except Exception:
133133
pass
134-
135-
136-
def cleanup_blocklists(client: StreamChat):
137-
"""Clean up test blocklists"""
138-
try:
139-
# Delete common test blocklist names
140-
test_blocklists = ["Foo", "TestBlocklist", "TestBlocklistAsync"]
141-
for blocklist_name in test_blocklists:
142-
try:
143-
client.delete_blocklist(blocklist_name)
144-
except Exception:
145-
pass # Blocklist might not exist
146-
except Exception:
147-
pass
148-
149-
150-
@pytest.fixture(autouse=True, scope="session")
151-
def cleanup_test_data():
152-
"""Global cleanup for test data"""
153-
yield
154-
# This runs after all tests complete
155-
# Add any global cleanup here if needed

stream_chat/tests/test_client.py

Lines changed: 13 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from stream_chat import StreamChat
1616
from stream_chat.base.exceptions import StreamAPIException
1717
from stream_chat.channel import Channel
18-
from stream_chat.tests.conftest import cleanup_blocklists, hard_delete_users
18+
from stream_chat.tests.conftest import hard_delete_users
1919
from stream_chat.tests.utils import wait_for
2020

2121

@@ -699,90 +699,26 @@ def test_query_channels_members_in(
699699
assert len(response["channels"][0]["members"]) == 9
700700

701701
def test_create_blocklist(self, client: StreamChat):
702-
# Use a unique name to avoid conflicts
703-
blocklist_name = f"TestBlocklist_{uuid.uuid4().hex[:8]}"
704-
client.create_blocklist(
705-
name=blocklist_name, words=["fudge", "heck"], type="word"
706-
)
707-
708-
# Clean up after test
709-
try:
710-
client.delete_blocklist(blocklist_name)
711-
except Exception:
712-
pass
702+
client.create_blocklist(name="Foo", words=["fudge", "heck"], type="word")
713703

714704
def test_list_blocklists(self, client: StreamChat):
715-
# First, clean up any existing test blocklists
716-
cleanup_blocklists(client)
717-
718-
# Create a test blocklist
719-
blocklist_name = f"TestBlocklist_{uuid.uuid4().hex[:8]}"
720-
client.create_blocklist(
721-
name=blocklist_name, words=["fudge", "heck"], type="word"
722-
)
723-
724-
try:
725-
response = client.list_blocklists()
726-
# Should have at least 1 blocklist (the one we just created)
727-
assert len(response["blocklists"]) >= 1
728-
blocklist_names = {
729-
blocklist["name"] for blocklist in response["blocklists"]
730-
}
731-
assert blocklist_name in blocklist_names
732-
finally:
733-
# Clean up
734-
try:
735-
client.delete_blocklist(blocklist_name)
736-
except Exception:
737-
pass
705+
response = client.list_blocklists()
706+
assert len(response["blocklists"]) == 2
707+
blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]}
708+
assert "Foo" in blocklist_names
738709

739710
def test_get_blocklist(self, client: StreamChat):
740-
blocklist_name = f"TestBlocklist_{uuid.uuid4().hex[:8]}"
741-
client.create_blocklist(
742-
name=blocklist_name, words=["fudge", "heck"], type="word"
743-
)
744-
745-
try:
746-
response = client.get_blocklist(blocklist_name)
747-
assert response["blocklist"]["name"] == blocklist_name
748-
assert response["blocklist"]["words"] == ["fudge", "heck"]
749-
finally:
750-
# Clean up
751-
try:
752-
client.delete_blocklist(blocklist_name)
753-
except Exception:
754-
pass
711+
response = client.get_blocklist("Foo")
712+
assert response["blocklist"]["name"] == "Foo"
713+
assert response["blocklist"]["words"] == ["fudge", "heck"]
755714

756715
def test_update_blocklist(self, client: StreamChat):
757-
blocklist_name = f"TestBlocklist_{uuid.uuid4().hex[:8]}"
758-
client.create_blocklist(
759-
name=blocklist_name, words=["fudge", "heck"], type="word"
760-
)
761-
762-
try:
763-
client.update_blocklist(blocklist_name, words=["dang"])
764-
response = client.get_blocklist(blocklist_name)
765-
assert response["blocklist"]["words"] == ["dang"]
766-
finally:
767-
# Clean up
768-
try:
769-
client.delete_blocklist(blocklist_name)
770-
except Exception:
771-
pass
716+
client.update_blocklist("Foo", words=["dang"])
717+
response = client.get_blocklist("Foo")
718+
assert response["blocklist"]["words"] == ["dang"]
772719

773720
def test_delete_blocklist(self, client: StreamChat):
774-
blocklist_name = f"TestBlocklist_{uuid.uuid4().hex[:8]}"
775-
client.create_blocklist(
776-
name=blocklist_name, words=["fudge", "heck"], type="word"
777-
)
778-
client.delete_blocklist(blocklist_name)
779-
780-
# Verify it's deleted
781-
try:
782-
client.get_blocklist(blocklist_name)
783-
pytest.fail("Blocklist should have been deleted")
784-
except Exception:
785-
pass # Expected - blocklist should not exist
721+
client.delete_blocklist("Foo")
786722

787723
def test_check_push(self, client: StreamChat, channel: Channel, random_user: Dict):
788724
msg = {"id": str(uuid.uuid4()), "text": "/giphy wave"}

0 commit comments

Comments
 (0)