Skip to content

Commit

Permalink
changed class order to match async
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Apr 18, 2024
1 parent 3c33954 commit 7c9c3bd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions google/cloud/bigtable/data/_sync/system_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
88 changes: 44 additions & 44 deletions tests/system/data/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 7c9c3bd

Please sign in to comment.