コード例 #1
0
def test_get_result_data__invalid_snapshot_id__raise_exception():
    # Arrange
    saver = Saver('sqlite://')
    api.readerInst = saver  # hot-wiring the 'api' to our mock db
    user_id = 13
    uname = 'testy'
    bday = 10101
    gender = 'm'
    saver.get_or_create_user_id(user_id, uname, bday, gender)
    parser_name = 'pose'
    snap_id = saver.update_or_create_snapshot(user_id, 1122, parser_name)
    content = "{'test':'tset'}"
    saver.save_parser_res(parser_name, snap_id, content)

    # Act
    with pytest.raises(Exception):
        res = api.get_result_data(user_id, 9988, parser_name)
コード例 #2
0
def test_get_parser_res__valid_ids__res_returned():
    # Arrange
    saver = Saver('sqlite://')
    api.readerInst = saver  # hot-wiring the 'api' to our mock db
    user_id = 13
    uname = 'testy'
    bday = 10101
    gender = 'm'
    saver.get_or_create_user_id(user_id, uname, bday, gender)
    parser_name = 'pose'
    snap_id = saver.update_or_create_snapshot(user_id, 1122, parser_name)
    content = "{'test':'tset'}"
    saver.save_parser_res(parser_name, snap_id, content)

    # Act
    res = api.get_result(user_id, snap_id, parser_name)

    # Assert
    assert res is not None
    assert res == content
コード例 #3
0
def test_save_parser_res__results_id_retured():
    in_mem_db_url = 'sqlite://'
    # Just making sure the line below doesn't throw
    s = Saver(in_mem_db_url)
    r = Reader(in_mem_db_url)
    r.engine = s.engine

    param_id = 1
    res_id = s.get_or_create_user_id(
        uid=param_id, name='Testy', bday=101010, gender='m')
    assert res_id == param_id
    # Line below should not throw, just return None
    parser_name = 'pose'
    data = "{'test':'tset'}"
    dtime = 1122
    snap_id = s.update_or_create_snapshot(
        uid=param_id,
        datetime=dtime,
        new_available_result=parser_name)
    res_id = s.save_parser_res(parser_name, snap_id, data)
    assert res_id is not None