|
15 | 15 | from stream_chat.async_chat import StreamChatAsync |
16 | 16 | from stream_chat.async_chat.channel import Channel |
17 | 17 | 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 |
22 | 19 | from stream_chat.tests.utils import wait_for_async |
23 | 20 |
|
24 | 21 |
|
@@ -725,89 +722,26 @@ async def test_query_channels_members_in( |
725 | 722 | assert len(response["channels"][0]["members"]) == 9 |
726 | 723 |
|
727 | 724 | 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") |
738 | 726 |
|
739 | 727 | 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 |
763 | 732 |
|
764 | 733 | 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"] |
780 | 737 |
|
781 | 738 | 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"] |
797 | 742 |
|
798 | 743 | 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") |
811 | 745 |
|
812 | 746 | async def test_check_push( |
813 | 747 | self, client: StreamChatAsync, channel: Channel, random_user: Dict |
|
0 commit comments