def test_position(self): name = 'test' sprite = 'imgs/dungeon_crawl/monster/angel.png' pos = random_position() entity = Entity(name, pos, sprite) self.assertTrue(entity.is_on_pos(pos)) self.assertTrue(entity.is_on_pos((pos[0] + rd.randint(0, TILE_SIZE), pos[1] + rd.randint(0, TILE_SIZE)))) self.assertFalse(entity.is_on_pos((pos[0] - rd.randint(0, MAIN_WIN_WIDTH), pos[1]))) self.assertFalse(entity.is_on_pos((pos[0], pos[1] - rd.randint(0, MAIN_WIN_HEIGHT))))
def test_init_entity(self): name = 'entity' pos = (3, 2) sprite = 'imgs/dungeon_crawl/monster/angel.png' entity = Entity(name, pos, sprite) self.assertEqual(name, entity.name) self.assertEqual(pos, entity.pos) self.assertEqual('Entity', str(entity)) self.assertTrue(entity.is_on_pos(pos))