Example #1
0
def test_list_items(mocked_dbo, random_ddb_pointer_table):
    mocked_dbo.table.scan = mock.Mock(return_value=random_ddb_pointer_table)
    expected_guids = set()
    for item in random_ddb_pointer_table["Items"]:
        partition_key = item[BaseItem.partition_key_name()]
        if not partition_key.startswith(ContextItem._prefix()):
            expected_guids.add(partition_key)
    pointers = mocked_dbo.list()
    actual_guids = set()
    for p in pointers:
        # Ensure we filtered out context keys
        assert ContextItem._prefix() not in p.partition_key
        # Add this guid
        actual_guids.add(p.partition_key)
    assert expected_guids == actual_guids
def test_validate_reserved_ec_keys_partition():
    with pytest.raises(DataModelException):
        PointerItem._validate_reserved_ec_keys(
            {BaseItem.partition_key_name(): "blammo"}
        )
def test_duplicate_keys_throw():
    data = bytes.fromhex("badbadbadbad")
    bonkers_context = {BaseItem.partition_key_name(): "kaboom"}
    with pytest.raises(DataModelException):
        DocumentBundle.from_data_and_context(data, bonkers_context)