Пример #1
0
def test_save_simple(store: DynamoStore) -> None:
    store.save(Key(KeyType.DIMENSION, 'test_user', 'test_group'), {
        'string_field': 'string',
        'int_field': 1
    })
    assert store.get(Key(KeyType.DIMENSION, 'test_user', 'test_group')) == {
        'string_field': 'string',
        'int_field': 1
    }
Пример #2
0
def test_save_time(store: DynamoStore) -> None:
    start_time = datetime(2018, 1, 1, 1, 1, 1, 1, tzinfo=timezone.utc)
    store.save(Key('test_user', 'test_group', start_time), {
        'string_field': 'string2',
        'int_field': 2
    })
    assert store.get(Key('test_user', 'test_group', start_time)) == {
        'string_field': 'string2',
        'int_field': 2
    }
Пример #3
0
def test_get_range_start_end_time_no_dimensions_match(
        loaded_store: DynamoStore) -> None:
    key = Key(KeyType.DIMENSION, 'user1', 'session_dim', ['dimC'])
    blocks = loaded_store.get_range(
        key, datetime(2018, 3, 7, 19, 35, 31, 0, timezone.utc),
        datetime(2018, 3, 7, 22, 38, 31, 0, timezone.utc))
    assert len(blocks) == 0
Пример #4
0
def test_get_range_count_negative_partial_dimensions_match(
        loaded_store: DynamoStore) -> None:
    key = Key(KeyType.DIMENSION, 'user1', 'session_dim', ['dimA'])
    blocks = loaded_store.get_range(
        key, datetime(2018, 3, 7, 22, 38, 31, 0, timezone.utc), None, -2)
    assert len(blocks) == 2
    assert blocks[0][1]['_start_time'] == datetime(2018, 3, 7, 19, 35, 31, 0,
                                                   timezone.utc).isoformat()
Пример #5
0
def test_get_range_count_backward(loaded_store: DynamoStore) -> None:
    items = loaded_store.get_range(
        Key('test_user', 'test_group',
            datetime(2018, 1, 1, 6, 1, 1, 1, tzinfo=timezone.utc)), None, -3)

    assert len(items) == 3
    assert items[0][1]['int_field'] == 5
    assert items[-1][1]['int_field'] == 3
Пример #6
0
def test_get_range_count_negative_from_first_element(
        loaded_store: DynamoStore, key_type_and_group) -> None:
    """
    Tests that the range get does not include the blocks that lie on the boundary
    """
    key = Key(key_type_and_group[0], 'user1', key_type_and_group[1])
    blocks = loaded_store.get_range(
        key, datetime(2018, 3, 7, 19, 35, 31, 0, timezone.utc), None, -2)
    assert len(blocks) == 0
Пример #7
0
def test_get_range_no_items_on_boundary(loaded_store: DynamoStore) -> None:
    items = loaded_store.get_range(
        Key('test_user', 'test_group',
            datetime(2018, 1, 1, 2, 1, 1, 0, tzinfo=timezone.utc)),
        Key('test_user', 'test_group',
            datetime(2018, 1, 1, 6, 1, 1, 2, tzinfo=timezone.utc)))

    assert len(items) == 5
    assert items[0][1]['int_field'] == 2
    assert items[-1][1]['int_field'] == 6
Пример #8
0
def test_get_range_count_negative(loaded_store: DynamoStore,
                                  key_type_and_group) -> None:
    """
    Tests that the range get does not include the blocks that lie on the boundary
    """
    key = Key(key_type_and_group[0], 'user1', key_type_and_group[1])
    blocks = loaded_store.get_range(
        key, datetime(2018, 3, 7, 22, 38, 31, 0, timezone.utc), None, -2)
    assert len(blocks) == 2
    assert blocks[0][1]['_start_time'] == datetime(2018, 3, 7, 20, 35, 35, 0,
                                                   timezone.utc).isoformat()
Пример #9
0
def test_get_all(loaded_store: DynamoStore) -> None:
    assert len(loaded_store.get_all('user1')) == 13
Пример #10
0
def test_get_all(loaded_store: DynamoStore) -> None:
    items = loaded_store.get_all('test_user')

    assert len(items) == 8