Exemplo n.º 1
0
def test_trim_snapshot():
    class dummy_obj:
        pass

    col_img = image(2, 2, b'\xff\x00\x00' * 4)
    dep_img = image(1, 1, struct.pack('!f', 0.75))
    trans = dummy_obj()
    trans.x = 1.1
    trans.y = 2.1
    trans.z = 3.1
    rot = dummy_obj()
    rot.x = 1.1
    rot.y = 2.2
    rot.z = 3.3
    rot.w = 4.4
    feel = dummy_obj()
    feel.hunger = 1.0
    feel.thirst = 0.0
    feel.exhaustion = -1.0
    feel.happiness = 1.0
    s1 = proto.Snapshot(proto.UserInfo(42, 'Name Name', 10101, 'm'), 2, trans,
                        rot, col_img, dep_img, feel)

    trim_snap = trim_snapshot(s1, ['pose'])

    assert trim_snap
    assert trim_snap is not s1
Exemplo n.º 2
0
def test_snapshot_ser_des_with_nones():
    col_img = image(2, 2, b'\xff\x00\x00' * 4)
    dep_img = image(1, 1, struct.pack('!f', 0.75))
    trans = None
    rot = None
    feel = None
    s1 = proto.Snapshot(TEST_USER_INFO, TEST_DATE_TIME, trans, rot, col_img,
                        dep_img, feel)
    s2 = proto.Snapshot.fromDict(s1.toDict())
    assert repr(s1) == repr(s2)
Exemplo n.º 3
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
Exemplo n.º 4
0
def test_snapshot_ser_des():
    class dummy_obj:
        pass

    col_img = image(2, 2, b'\xff\x00\x00' * 4)
    dep_img = image(1, 1, struct.pack('!f', 0.75))
    trans = dummy_obj()
    trans.x = 1.1
    trans.y = 2.1
    trans.z = 3.1
    rot = dummy_obj()
    rot.x = 1.1
    rot.y = 2.2
    rot.z = 3.3
    rot.w = 4.4
    feel = dummy_obj()
    feel.hunger = 1.0
    feel.thirst = 0.0
    feel.exhaustion = -1.0
    feel.happiness = 1.0
    s1 = proto.Snapshot(TEST_USER_INFO, TEST_DATE_TIME, trans, rot, col_img,
                        dep_img, feel)
    s2 = proto.Snapshot.fromDict(s1.toDict())
    assert repr(s1) == repr(s2)
Exemplo n.º 5
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()