Esempio n. 1
0
def test_lists_dto_get_all__if_user_has_no_lists__then_return_empty_list(
        dynamodb_lists_table, dynamodb_user_to_lists_table, sample_data):
    from sf_shopping_list.data.dto.lists_dto import ListsDto
    from sf_shopping_list.data.clients.dynamodb import user_to_lists_table

    user_to_lists_table().put_item(Item={
        'user_id': tested_user_id,
        'lists': [],
    })

    res = ListsDto.get_all(tested_user_id)
    assert res == []
Esempio n. 2
0
def test_lists_dto_get_all__if_user_has_guest_access_to_the_list__then_return_the_list(
        dynamodb_lists_table, dynamodb_user_to_lists_table, sample_data):
    from sf_shopping_list.data.dto.lists_dto import ListsDto
    from sf_shopping_list.data.clients.dynamodb import lists_table, user_to_lists_table

    list1 = sample_data['lists'][1]
    lists_table().put_item(Item=list1)
    user_to_lists_table().put_item(Item={
        'user_id': tested_user_id,
        'lists': [list1['id']]
    })

    res = ListsDto.get_all(tested_user_id)
    assert len(res) == 1
    assert ListMappers.map_dto_to_doc(
        res[0]) == ListDocModel.from_db_doc(list1)
Esempio n. 3
0
def get_lists():
    assert isinstance(app.current_event, APIGatewayProxyEventV2)
    sub = _get_auth_user_sub(app.current_event)
    return ListsDto.get_all(sub)