From 7c9c3bdf40277b2af9805f59fa449cedfa839223 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 18 Apr 2024 11:41:52 -0700 Subject: [PATCH] changed class order to match async --- .../bigtable/data/_sync/system_tests.yaml | 4 +- tests/system/data/test_system.py | 88 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/google/cloud/bigtable/data/_sync/system_tests.yaml b/google/cloud/bigtable/data/_sync/system_tests.yaml index b6f3e64eb..d8a3c7c53 100644 --- a/google/cloud/bigtable/data/_sync/system_tests.yaml +++ b/google/cloud/bigtable/data/_sync/system_tests.yaml @@ -15,10 +15,10 @@ text_replacements: aclose: close classes: + - path: tests.system.data.test_system_async.TempRowBuilder + autogen_sync_name: TempRowBuilder - path: tests.system.data.test_system_async.TestSystemAsync autogen_sync_name: TestSystemSync drop_methods: ["event_loop"] - - path: tests.system.data.test_system_async.TempRowBuilder - autogen_sync_name: TempRowBuilder save_path: "tests/system/data/test_system.py" diff --git a/tests/system/data/test_system.py b/tests/system/data/test_system.py index e8ad50a74..3ed20f1e1 100644 --- a/tests/system/data/test_system.py +++ b/tests/system/data/test_system.py @@ -30,6 +30,50 @@ from google.cloud.environment_vars import BIGTABLE_EMULATOR +class TempRowBuilder(ABC): + """ + Used to add rows to a table for testing purposes. + """ + + def __init__(self, table): + self.rows = [] + self.table = table + + def add_row( + self, row_key, *, family=TEST_FAMILY, qualifier=b"q", value=b"test-value" + ): + if isinstance(value, str): + value = value.encode("utf-8") + elif isinstance(value, int): + value = value.to_bytes(8, byteorder="big", signed=True) + request = { + "table_name": self.table.table_name, + "row_key": row_key, + "mutations": [ + { + "set_cell": { + "family_name": family, + "column_qualifier": qualifier, + "value": value, + } + } + ], + } + self.table.client._gapic_client.mutate_row(request) + self.rows.append(row_key) + + def delete_rows(self): + if self.rows: + request = { + "table_name": self.table.table_name, + "entries": [ + {"row_key": row, "mutations": [{"delete_from_row": {}}]} + for row in self.rows + ], + } + self.table.client._gapic_client.mutate_rows(request) + + class TestSystemSync(ABC): @pytest.fixture(scope="session") def client(self): @@ -737,47 +781,3 @@ def test_literal_value_filter( assert len(row_list) == bool( expect_match ), f"row {type(cell_value)}({cell_value}) not found with {type(filter_input)}({filter_input}) filter" - - -class TempRowBuilder(ABC): - """ - Used to add rows to a table for testing purposes. - """ - - def __init__(self, table): - self.rows = [] - self.table = table - - def add_row( - self, row_key, *, family=TEST_FAMILY, qualifier=b"q", value=b"test-value" - ): - if isinstance(value, str): - value = value.encode("utf-8") - elif isinstance(value, int): - value = value.to_bytes(8, byteorder="big", signed=True) - request = { - "table_name": self.table.table_name, - "row_key": row_key, - "mutations": [ - { - "set_cell": { - "family_name": family, - "column_qualifier": qualifier, - "value": value, - } - } - ], - } - self.table.client._gapic_client.mutate_row(request) - self.rows.append(row_key) - - def delete_rows(self): - if self.rows: - request = { - "table_name": self.table.table_name, - "entries": [ - {"row_key": row, "mutations": [{"delete_from_row": {}}]} - for row in self.rows - ], - } - self.table.client._gapic_client.mutate_rows(request)