Exemple #1
0
def test_translation_feelings(tmp_path):
    my_dir = tmp_path / 'my_dir'
    my_dir.mkdir()
    feel = {
        'hunger': 1.1,
        'thirst': 2.2,
        'exhaustion': 3.3,
        'happiness': 4.4,
    }

    snap = SnapshotSlim(TEST_USER_INFO, TEST_DATE_TIME, None, None, None, None,
                        feel)
    res = parsers.run_parser('feelings', json.dumps(snap.toDict()))
    j = json.loads(res)
    j = json.loads(j['parser_res'])
    assert 'hunger' in j
    assert 'thirst' in j
    assert 'exhaustion' in j
    assert 'happiness' in j
Exemple #2
0
def test__depth_image__get_encoded_image_called(tmp_path):
    my_dir = tmp_path / 'my_dir'
    my_dir.mkdir()
    img = image(2, 2, [0.0, 1.0, 1.0, 0.0])
    img_path = my_dir / 'image.bin'

    snap = SnapshotSlim(TEST_USER_INFO, TEST_DATE_TIME, None, None, None,
                        img_path, None)
    con = parser_context(my_dir)
    con.set_encoded_image_to_return(img)
    parser = parsers.registered_parsers['depth_image']
    parser(con, snap)
    assert con.get_encoded_image != 0
Exemple #3
0
def test__depth_image__write(tmp_path):
    my_dir = tmp_path / 'my_dir'
    my_dir.mkdir()
    img = image(2, 2, [0.0, 1.0, 1.0, 0.0])
    img_path = my_dir / 'image.bin'

    snap = SnapshotSlim(TEST_USER_INFO, TEST_DATE_TIME, None, None, None,
                        img_path, None)
    con = parser_context(my_dir)
    con.set_encoded_image_to_return(img)
    parser = parsers.registered_parsers['depth_image']
    res = parser(con, snap)
    assert res is not None
    res_dict = json.loads(res)
    assert res_dict['data_path'] is not None
    assert Path(res_dict['data_path']).is_file()
Exemple #4
0
def test_translation_content(tmp_path):
    my_dir = tmp_path / 'my_dir'
    my_dir.mkdir()
    translation = {'x': 1.1, 'y': 2.2, 'z': 3.3}
    rot = {'x': 1.1, 'y': 2.2, 'z': 3.3, 'w': 4.4}
    snap = SnapshotSlim(TEST_USER_INFO, TEST_DATE_TIME, translation, rot, None,
                        None, None)
    con = parser_context(my_dir)
    res = parsers.registered_parsers['pose'](con, snap)
    j = json.loads(res)
    assert 'translation' in j
    retr_trans = j['translation']
    assert 'x' in retr_trans
    assert 'y' in retr_trans
    assert 'z' in retr_trans
    for k in retr_trans:
        assert math.isclose(retr_trans[k], translation[k])
Exemple #5
0
def test_translation_feelings(tmp_path):
    my_dir = tmp_path / 'my_dir'
    my_dir.mkdir()
    feel = {
        'hunger': 1.1,
        'thirst': 2.2,
        'exhaustion': 3.3,
        'happiness': 4.4,
    }

    snap = SnapshotSlim(TEST_USER_INFO, TEST_DATE_TIME, None, None, None, None,
                        feel)
    con = parser_context(my_dir)
    res = parsers.registered_parsers['feelings'](con, snap)
    j = json.loads(res)
    assert 'hunger' in j
    assert 'thirst' in j
    assert 'exhaustion' in j
    assert 'happiness' in j