Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 6fa49ab

Browse files
committed
iterating on tests
1 parent 73171eb commit 6fa49ab

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

tests/system/data/test_system.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,27 @@ async def test_check_and_mutate(
595595
expected_value = true_mutation_value if expected_result else false_mutation_value
596596
assert (await _retrieve_cell_value(table, row_key)) == expected_value
597597

598+
@pytest.mark.skipif(
599+
bool(os.environ.get(BIGTABLE_EMULATOR)),
600+
reason="emulator doesn't raise InvalidArgument",
601+
)
602+
@pytest.mark.usefixtures("client")
603+
@pytest.mark.usefixtures("table")
604+
@pytest.mark.asyncio
605+
async def test_check_and_mutate_empty_request(client, table):
606+
"""
607+
check_and_mutate with no true or fale mutations should raise an error
608+
"""
609+
from google.api_core import exceptions
610+
611+
with pytest.raises(exceptions.InvalidArgument) as e:
612+
await table.check_and_mutate_row(
613+
b'row_key',
614+
None,
615+
true_case_mutations=None,
616+
false_case_mutations=None
617+
)
618+
assert "No mutations provided" in str(e.value)
598619

599620
@pytest.mark.usefixtures("table")
600621
@retry.AsyncRetry(predicate=retry.if_exception_type(ClientError), initial=1, maximum=5)

tests/unit/data/_async/test_client.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ def _make_one(self, *args, use_emulator=True, **kwargs):
5858
# emulator mode must be disabled by tests that check channel pooling/refresh background tasks
5959
if use_emulator:
6060
env_mask["BIGTABLE_EMULATOR_HOST"] = "localhost"
61+
else:
62+
# set some default values
63+
kwargs["credentials"] = kwargs.get("credentials", AnonymousCredentials())
64+
kwargs["project"] = kwargs.get("project", "project-id")
6165
with mock.patch.dict(os.environ, env_mask):
6266
return self._get_target_class()(*args, **kwargs)
6367

@@ -2758,22 +2762,6 @@ async def test_check_and_mutate_bad_timeout(self):
27582762
)
27592763
assert str(e.value) == "operation_timeout must be greater than 0"
27602764

2761-
@pytest.mark.asyncio
2762-
async def test_check_and_mutate_no_mutations(self):
2763-
"""Requests require either true_case_mutations or false_case_mutations"""
2764-
from google.api_core.exceptions import InvalidArgument
2765-
2766-
async with self._make_client() as client:
2767-
async with client.get_table("instance", "table") as table:
2768-
with pytest.raises(InvalidArgument) as e:
2769-
await table.check_and_mutate_row(
2770-
b"row_key",
2771-
None,
2772-
true_case_mutations=None,
2773-
false_case_mutations=None,
2774-
)
2775-
assert "No mutations provided" in str(e.value)
2776-
27772765
@pytest.mark.asyncio
27782766
async def test_check_and_mutate_single_mutations(self):
27792767
"""if single mutations are passed, they should be internally wrapped in a list"""

0 commit comments

Comments
 (0)