Skip to content

Commit

Permalink
ensure existing tests target sub v3 client
Browse files Browse the repository at this point in the history
  • Loading branch information
jchapian committed Oct 31, 2024
1 parent 7b8acaf commit da52249
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion gcp_flowlogs_reader/gcp_flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def page_helper(logging_client, wait_time=1.0, **kwargs):
iterator = logging_client.list_entries(**kwargs)
while True:
try:
iterator = logging_client.list_entries(**kwargs)
for page in iterator.pages:
kwargs['page_token'] = iterator.next_page_token
yield from page
Expand Down
17 changes: 15 additions & 2 deletions tests/test_gcp_flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ def __next__(self):
class TestClient(Client):
_credentials = ''

def list_entries(
self,
*,
projects=None,
filter_=None,
order_by=None,
max_results=None,
page_size=None,
page_token=None,
):
pass


class FlowRecordTests(TestCase):
def test_init_outbound(self):
Expand Down Expand Up @@ -372,6 +384,7 @@ def test_resource_labels(self):


@patch(PREFIX('LoggingClient'), autospec=TestClient)
@patch(PREFIX('gcp_logging_version'), '1.12.2')
class ReaderTests(TestCase):
def test_init_with_client(self, MockLoggingClient):
logging_client = MagicMock(Client)
Expand Down Expand Up @@ -712,10 +725,10 @@ def test_custom_key(self):
)


@patch(PREFIX('gcp_logging_version'), '1.12.2')
class MainCLITests(TestCase):
def setUp(self):
patch_path = PREFIX('LoggingClient')
with patch(patch_path, autospec=True) as MockLoggingClient:
with patch(PREFIX('LoggingClient'), autospec=TestClient) as MockLoggingClient:
MockLoggingClient.return_value.project = 'yoyodyne-102010'
MockLoggingClient.return_value.list_entries.return_value = MockIterator()
self.reader = Reader()
Expand Down

0 comments on commit da52249

Please sign in to comment.