def test_create(self): a = Actor("lovely head") result = a.to_json(indent=4) # print(result) b = Actor().from_json(result) assert isinstance(b, Actor) assert isinstance(b._clickable_area, Rect)
def test_getgoto_action_motion(self): a = Actor("astronaut").smart( None, using=Path(TEST_PATH, "data/actors/astronaut").as_posix()) a.x = 50 a.y = 50 action, motion = a.getgoto_action_motion(100, 100) assert action == "right" assert motion == "right"
def test_create_smart(self): a = Actor("astronaut").smart( None, using=Path(TEST_PATH, "data/actors/astronaut").as_posix()) result = a.to_json(indent=4) # print(result) b = Actor().from_json(result) assert isinstance(b, Actor) assert isinstance(list(b.actions.values())[0], Action)
def test_smart(self): game = Game(resolution=(100, 100)) game.autoscale = False game.working_directory = "/home/luke/Projects/pyvida/test_data" a = Actor("Adam") a.smart(game) assert list(a.actions.keys()) == ["idle"] assert a.resource_name == "Adam"
def set_up(self): self.game = Game("Unit Tests", fps=60, afps=16, resolution=RESOLUTION) self.game.settings = Settings() self.actor = Actor("_test_actor").smart(self.game) self.msgbox = Item("msgbox").smart(self.game, using="data/items/_test_item") self.ok = Item("ok").smart(self.game, using="data/items/_test_item") self.scene = Scene("_test_scene") self.item = Item("test_item") self.game.add( [self.scene, self.actor, self.msgbox, self.ok, self.item]) self.scene.immediate_add(self.actor) self.game.scene = self.scene
class TestEvents: def set_up(self): self.game = Game("Unit Tests", fps=60, afps=16, resolution=RESOLUTION) self.game.settings = Settings() self.actor = Actor("_test_actor").smart(self.game) self.msgbox = Item("msgbox").smart(self.game, using="data/items/_test_item") self.ok = Item("ok").smart(self.game, using="data/items/_test_item") self.scene = Scene("_test_scene") self.item = Item("test_item") self.game.add( [self.scene, self.actor, self.msgbox, self.ok, self.item]) self.scene.immediate_add(self.actor) self.game.scene = self.scene def test_relocate(self): # setup self.set_up() self.actor.relocate(self.scene) event = self.game.events[0] assert len(self.game.events) == 1 assert event[0].__name__ == "relocate" assert event[1] == self.actor assert event[2][0] == self.scene
def test_load_assets(self): game = Game(resolution=(100, 100)) game.autoscale = False game.working_directory = "/home/luke/Projects/pyvida/test_data" a = Actor("Adam") a.smart(game) a.load_assets(game) resource = get_resource(a.resource_name) action = a.get_action() assert resource[0] == 249 assert resource[1] == 341 assert action.w == 249 assert action.h == 341 assert type(resource[2]) == PyvidaSprite assert list(a.actions.keys()) == ["idle"]
def test_calculate_goto(self): a = Actor("astronaut").smart( None, using=Path(TEST_PATH, "data/actors/astronaut").as_posix()) a._calculate_goto(destination=(1000, 1000))
def test_motion_manager(self): # test has inherited correctled. obj = Actor("test") obj.applied_motions.append("hello") assert len(obj.applied_motions) == 1