def test_query_order_desc_and_asc():
    names = ['Felipe Volpone','Gustavo Silverio','Guilherme Gotardo']
    for i in xrange(0, 3):
        put_entity_json['fields'][1]['value'] = names[i]
        entity_api.put(put_entity_json)

    json = query_api.execute(query_asc_and_desc_2)
    for index, entity in enumerate(get_fields(json)):
        for field in entity:
            if 'name' in field['field']:
                assert names[index] == field['value']
def test_query_order_desc_and_asc():
    names = ['Felipe Volpone', 'Gustavo Silverio', 'Guilherme Gotardo']
    for i in xrange(0, 3):
        put_entity_json['fields'][1]['value'] = names[i]
        entity_api.put(put_entity_json)

    json = query_api.execute(query_asc_and_desc_2)
    for index, entity in enumerate(get_fields(json)):
        for field in entity:
            if 'name' in field['field']:
                assert names[index] == field['value']
def test_basic_query_with_filter_operator_lt():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_lt)
    for fields in get_fields(json):
        for field in fields:

            if 'idade' in field:
                assert field['field'] == '21'

    json = query_api.execute(query_lt_no_result)
    assert len(json['result']) == 0
Exemple #4
0
def test_basic_query_with_filter_operator_in():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_in)
    for fields in get_fields(json):
        for field in fields:

            if 'nome' in field:
                assert field['field'] == 'Luana Silva'

    json = query_api.execute(query_in_no_result)
    assert len(json['result']) == 0
Exemple #5
0
def test_basic_query_with_filter_operator_lt():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_lt)
    for fields in get_fields(json):
        for field in fields:

            if 'idade' in field:
                assert field['field'] == '21'

    json = query_api.execute(query_lt_no_result)
    assert len(json['result']) == 0
def test_basic_query_with_filter_operator_in():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_in)
    for fields in get_fields(json):
        for field in fields:

            if 'nome' in field:
                assert field['field'] == 'Luana Silva'

    json = query_api.execute(query_in_no_result)
    assert len(json['result']) == 0
def test_date_type():
    for i in xrange(0, len(some_dates)):
        change_name(i)
        change_date(i)

        entity_api.put(entity)

    result = query_api.execute(search_date)
    assert 1 == len(result['result'])

    for fields in result['result'][0]['fields']:
        if fields['field'] == 'nome':
            assert "jose" == fields['value']
def test_date_type():
    for i in xrange(0, len(some_dates)):
        change_name(i)
        change_date(i)

        entity_api.put(entity)

    result = query_api.execute(search_date)
    assert 1 == len(result['result'])

    for fields in result['result'][0]['fields']:
        if fields['field'] == 'nome':
            assert "jose" == fields['value']
Exemple #9
0
def test_get_entity_by_key():
    entity_api.put(entity_father)

    father_json = query_api.execute(query_operator_eq_father)
    assert len(father_json['result']) == 1

    change_id_of_son_and_change_query(father_json, entity_son)
    entity_api.put(entity_son)

    son_json = query_api.execute(query_find_father_by_key_id)
    assert len(son_json['result']) == 1

    assert get_father_id(father_json) == son_json['result'][0]['id']

    result_name = son_json['result'][0]['fields'][0]['value']
    assert FATHERS_NAME == result_name
def test_get_entity_by_key():
    entity_api.put(entity_father)

    father_json = query_api.execute(query_operator_eq_father)
    assert len(father_json['result']) == 1

    change_id_of_son_and_change_query(father_json, entity_son)
    entity_api.put(entity_son)

    son_json = query_api.execute(query_find_father_by_key_id)
    assert len(son_json['result']) == 1

    assert get_father_id(father_json) == son_json['result'][0]['id']

    result_name = son_json['result'][0]['fields'][0]['value']
    assert FATHERS_NAME == result_name
Exemple #11
0
def test_find_by_id():
    entity_api.put(entity_another_guy)
    entity_api.put(entity_son)
    entity_api.put(entity_father)

    father = query_api.execute(query_operator_eq_father)
    assert len(father['result']) == 1

    father_id = get_father_id(father)
    query_find_by_id['id'] = father_id

    result = query_api.execute(query_find_by_id)
    assert len(result['result']) == 1
def test_find_by_id():
    entity_api.put(entity_another_guy)
    entity_api.put(entity_son)
    entity_api.put(entity_father)

    father = query_api.execute(query_operator_eq_father)
    assert len(father['result']) == 1

    father_id = get_father_id(father)
    query_find_by_id['id'] = father_id

    result = query_api.execute(query_find_by_id)
    assert len(result['result']) == 1
def test_get_ancestor():
    entity_api.put(entity_another_guy)
    entity_api.put(entity_father)

    father = query_api.execute(query_operator_eq_father)
    assert len(father['result']) == 1

    father_id = get_father_id(father)
    entity_son_ancestor['ancestor']['id'] = father_id
    query_find_son_by_ancestor['ancestor']['id'] = father_id

    entity_api.put(entity_son_ancestor)
    result_by_ancestor = query_api.execute(query_find_son_by_ancestor)
    assert len(result_by_ancestor['result']) == 2

    for user in result_by_ancestor['result']:
        name = user['fields'][0]['value']
        if name == SONS_NAME:
            assert True
        elif name == FATHERS_NAME:
            assert father_id == user['id']
Exemple #14
0
def test_get_ancestor():
    entity_api.put(entity_another_guy)
    entity_api.put(entity_father)

    father = query_api.execute(query_operator_eq_father)
    assert len(father['result']) == 1

    father_id = get_father_id(father)
    entity_son_ancestor['ancestor']['id'] = father_id
    query_find_son_by_ancestor['ancestor']['id'] = father_id

    entity_api.put(entity_son_ancestor)
    result_by_ancestor = query_api.execute(query_find_son_by_ancestor)
    assert len(result_by_ancestor['result']) == 2

    for user in result_by_ancestor['result']:
        name = user['fields'][0]['value']
        if name == SONS_NAME:
            assert True
        elif name == FATHERS_NAME:
            assert father_id == user['id']
def put_user_changing_ages():
    for i in xrange(0, 3):
        put_entity_json['fields'][2]['value'] = 21 + i
        entity_api.put(put_entity_json)
def test_projection_query():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_fields)
    assert len(json['result'][0]['fields']) == 2
def test_max_limit():
    for i in xrange(0, 35):
        entity_api.put(put_entity_json)

    json = query_api.execute(query_limit)
    assert len(json['result']) == 30
def put():
    inserted_key = entity_api.put(request.json)
    return inserted_key
def test_max_limit():
    for i in xrange(0, 35):
        entity_api.put(put_entity_json)

    json = query_api.execute(query_limit)
    assert len(json['result']) == 30
def test_projection_query():
    entity_api.put(put_entity_json)

    json = query_api.execute(query_fields)
    assert len(json['result'][0]['fields']) == 2
Exemple #21
0
def test_create_entity():
    entity_api.put(json)

    entity = create_generic_model('User')
    query = entity.query()
    assert len(query.fetch()) == 1
def put_user_changing_ages():
    for i in xrange(0, 3):
        put_entity_json['fields'][2]['value'] = 21 + i
        entity_api.put(put_entity_json)