Skip to content

Commit 4ca9714

Browse files
author
Andrew Pope
committed
add unit tests
Signed-off-by: Andrew Pope <apope@nursefly.com>
1 parent 93ec924 commit 4ca9714

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

sdk/python/tests/unit/infra/online_store/test_dynamodb_online_store.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,42 @@ def test_write_batch_non_duplicates(repo_config, dynamodb_online_store):
318318
returned_items = response.get("Items", None)
319319
assert returned_items is not None
320320
assert len(returned_items) == len(data)
321+
322+
323+
@mock_dynamodb2
324+
def test_dynamodb_online_store_online_read_unknown_entity_end_of_batch(
325+
repo_config, dynamodb_online_store
326+
):
327+
"""
328+
Test DynamoDBOnlineStore online_read method with unknown entities at
329+
the end of the batch.
330+
"""
331+
batch_size = repo_config.online_store.batch_size
332+
n_samples = batch_size
333+
_create_test_table(PROJECT, f"{TABLE_NAME}_unknown_entity_{n_samples}", REGION)
334+
data = _create_n_customer_test_samples(n=n_samples)
335+
_insert_data_test_table(
336+
data, PROJECT, f"{TABLE_NAME}_unknown_entity_{n_samples}", REGION
337+
)
338+
339+
entity_keys, features, *rest = zip(*data)
340+
entity_keys = list(entity_keys)
341+
features = list(features)
342+
343+
# Append a nonsensical entity to search for as the only item in the 2nd batch
344+
entity_keys.append(
345+
EntityKeyProto(
346+
join_keys=["customer"], entity_values=[ValueProto(string_val="12359")]
347+
)
348+
)
349+
features.append(None)
350+
351+
returned_items = dynamodb_online_store.online_read(
352+
config=repo_config,
353+
table=MockFeatureView(name=f"{TABLE_NAME}_unknown_entity_{n_samples}"),
354+
entity_keys=entity_keys,
355+
)
356+
357+
# ensure the entity is not dropped
358+
assert len(returned_items) == len(entity_keys)
359+
assert returned_items[-1] == (None, None)

0 commit comments

Comments
 (0)