|
62 | 62 | def publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]: |
63 | 63 | yield pubsub_v1.PublisherClient() |
64 | 64 |
|
| 65 | +@pytest.fixture(scope="module") |
| 66 | +def publisher_client_with_default_compression() -> Generator[pubsub_v1.PublisherClient, None, None]: |
| 67 | + yield pubsub_v1.PublisherClient(publisher_options=pubsub_v1.types.PublisherOptions(enable_grpc_compression=True)) |
| 68 | + |
| 69 | +@pytest.fixture(scope="module") |
| 70 | +def publisher_client_with_low_compression() -> Generator[pubsub_v1.PublisherClient, None, None]: |
| 71 | + yield pubsub_v1.PublisherClient(publisher_options=pubsub_v1.types.PublisherOptions(enable_grpc_compression=True, compression_bytes_threshold=0)) |
65 | 72 |
|
66 | 73 | @pytest.fixture(scope="module") |
67 | 74 | def regional_publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]: |
@@ -791,6 +798,36 @@ def eventually_consistent_test() -> None: |
791 | 798 | eventually_consistent_test() |
792 | 799 |
|
793 | 800 |
|
| 801 | +def test_listen_for_errors_default_compression( |
| 802 | + publisher_client_with_default_compression: pubsub_v1.PublisherClient, |
| 803 | + topic: str, |
| 804 | + subscription_async: str, |
| 805 | + capsys: CaptureFixture[str], |
| 806 | +) -> None: |
| 807 | + _ = _publish_messages(publisher_client_with_default_compression, topic) |
| 808 | + |
| 809 | + subscriber.listen_for_errors(PROJECT_ID, SUBSCRIPTION_ASYNC, 5) |
| 810 | + |
| 811 | + out, _ = capsys.readouterr() |
| 812 | + assert subscription_async in out |
| 813 | + assert "threw an exception" in out |
| 814 | + |
| 815 | + |
| 816 | +def test_listen_for_errors_low_compression( |
| 817 | + publisher_client_with_low_compression: pubsub_v1.PublisherClient, |
| 818 | + topic: str, |
| 819 | + subscription_async: str, |
| 820 | + capsys: CaptureFixture[str], |
| 821 | +) -> None: |
| 822 | + _ = _publish_messages(publisher_client_with_low_compression, topic) |
| 823 | + |
| 824 | + subscriber.listen_for_errors(PROJECT_ID, SUBSCRIPTION_ASYNC, 5) |
| 825 | + |
| 826 | + out, _ = capsys.readouterr() |
| 827 | + assert subscription_async in out |
| 828 | + assert "threw an exception" in out |
| 829 | + |
| 830 | + |
794 | 831 | def test_receive_synchronously( |
795 | 832 | publisher_client: pubsub_v1.PublisherClient, |
796 | 833 | topic: str, |
|
0 commit comments