예제 #1
0
def test_island(resourcepath):
    success, world_uid = micropsi.new_world("Misland",
                                            "Island",
                                            owner="tester")
    assert success
    world = runtime.worlds[world_uid]
    assert world.__class__.__name__ == 'Island'
    runtime.add_worldobject(world_uid,
                            "Lightsource", (10, 10),
                            uid='foobar',
                            name='foobar',
                            parameters={})
    runtime.save_world(world_uid)
    runtime.revert_world(world_uid)
    world = runtime.worlds[world_uid]
    assert world.objects["foobar"].__class__.__name__ == 'Lightsource'
    assert world.objects["foobar"].position == [10, 10]
    assert world.data['objects']['foobar']['position'] == [10, 10]
    assert world.__class__.__name__ == 'Island'
    runtime.set_worldobject_properties(world_uid, "foobar", position=(5, 5))
    assert world.objects["foobar"].position == (5, 5)
    assert world.data['objects']['foobar']['position'] == (5, 5)
    assert runtime.get_world_view(world_uid,
                                  -1)['objects']['foobar']['position'] == (5,
                                                                           5)
    runtime.delete_world(world_uid)
def test_set_object_properties(test_world):
    world = runtime.get_available_worlds()[test_world]
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    runtime.set_worldobject_properties(test_world, "foobar", position=(5, 5))
    assert world.objects["foobar"].position == (5, 5)
    assert world.data['objects']['foobar']['position'] == (5, 5)
    assert runtime.get_world_view(test_world, -1)['objects']['foobar']['position'] == (5, 5)
예제 #3
0
def test_set_object_properties(test_world):
    world = runtime.get_available_worlds()[test_world]
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    runtime.set_worldobject_properties(test_world, "foobar", position=(5, 5))
    assert world.objects["foobar"].position == (5, 5)
    assert world.data['objects']['foobar']['position'] == (5, 5)
    assert runtime.get_world_view(test_world, -1)['objects']['foobar']['position'] == (5, 5)
def test_get_worldobjects(test_world):
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    objects = runtime.get_world_objects(test_world)
    assert 'foobar' in objects
    runtime.save_world(test_world)
    runtime.revert_world(test_world)
    objects = runtime.get_world_objects(test_world)
    assert 'foobar' in objects
예제 #5
0
def test_get_worldobjects(test_world):
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    objects = runtime.get_world_objects(test_world)
    assert 'foobar' in objects
    runtime.save_world(test_world)
    runtime.revert_world(test_world)
    objects = runtime.get_world_objects(test_world)
    assert 'foobar' in objects
def test_add_worldobject(test_world):
    world = runtime.get_available_worlds()[test_world]
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    assert "foobar" in world.data['objects']
    assert "foobar" in world.objects
    runtime.save_world(test_world)
    runtime.revert_world(test_world)
    assert "foobar" in world.data['objects']
    assert "foobar" in world.objects
예제 #7
0
def test_add_worldobject_without_id(test_world):
    world = runtime.get_available_worlds()[test_world]
    count = len(world.objects)
    runtime.add_worldobject(test_world,
                            "Default", (10, 10),
                            name='bazbaz',
                            parameters={})
    assert count + 1 == len(world.objects)
    assert count + 1 == len(world.data['objects'])
예제 #8
0
def test_add_worldobject(test_world):
    world = runtime.get_available_worlds()[test_world]
    runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
    assert "foobar" in world.data['objects']
    assert "foobar" in world.objects
    runtime.save_world(test_world)
    runtime.revert_world(test_world)
    assert "foobar" in world.data['objects']
    assert "foobar" in world.objects
예제 #9
0
def test_island(resourcepath):
    success, world_uid = micropsi.new_world("Misland", "Island", owner="tester")
    assert success
    world = runtime.worlds[world_uid]
    assert world.__class__.__name__ == 'Island'
    runtime.add_worldobject(world_uid, "Lightsource", (10, 10), uid='foobar', name='foobar', parameters={})
    runtime.save_world(world_uid)
    runtime.revert_world(world_uid)
    world = runtime.worlds[world_uid]
    assert world.objects["foobar"].__class__.__name__ == 'Lightsource'
    assert world.objects["foobar"].position == [10, 10]
    assert world.data['objects']['foobar']['position'] == [10, 10]
    assert world.__class__.__name__ == 'Island'
    runtime.set_worldobject_properties(world_uid, "foobar", position=(5, 5))
    assert world.objects["foobar"].position == (5, 5)
    assert world.data['objects']['foobar']['position'] == (5, 5)
    assert runtime.get_world_view(world_uid, -1)['objects']['foobar']['position'] == (5, 5)
    runtime.delete_world(world_uid)
예제 #10
0
def add_worldobject(world_uid, type, position, orientation=0.0, name="", parameters=None, uid=None):
    return runtime.add_worldobject(world_uid, type, position, orientation=orientation, name=name, parameters=parameters, uid=uid)
예제 #11
0
def add_worldobject(world_uid, type, position, orientation=0.0, name="", parameters=None, uid=None):
    result, uid = runtime.add_worldobject(world_uid, type, position, orientation=orientation, name=name, parameters=parameters, uid=uid)
    if result:
        return dict(status="success", uid=uid)
    else:
        return dict(status="error", msg=uid)
def test_add_worldobject_without_id(test_world):
    world = runtime.get_available_worlds()[test_world]
    count = len(world.objects)
    runtime.add_worldobject(test_world, "Default", (10, 10), name='bazbaz', parameters={})
    assert count + 1 == len(world.objects)
    assert count + 1 == len(world.data['objects'])
예제 #13
0
def add_worldobject(world_uid, type, position, orientation=0.0, name="", parameters=None):
    """ Add a worldobject of the given type """
    return runtime.add_worldobject(world_uid, type, position, orientation=float(orientation), name=name, parameters=parameters)