class TestWorldMapService(object): TEST_IMAGE_FILE = "../resources/test_data/image_detection/world_mixed/vlcsnap-2016-02-26-18h23m51s955.png" BLANK_IMAGE_FILE = "../resources/test_data/image_detection/blank_image.png" SAMPLE_PATH = Path() @classmethod def setup_class(cls): cls.test_image = Image.from_file(cls.TEST_IMAGE_FILE) cls.blank_test_image = Image.from_file(cls.BLANK_IMAGE_FILE) def setup(self): self._world_map_service = WorldMapService(CoordinateFactory()) def test_given_test_image_when_detecting_objects_then_objects_are_detected(self): self._world_map = self._world_map_service.detect_objects(self.test_image) assert_true(self._world_map.contains(WorldObjectType.PLAYFIELD)) assert_true(self._world_map.contains(WorldObjectType.ISLAND)) assert_true(self._world_map.contains(WorldObjectType.TREASURE)) assert_true(self._world_map.contains(WorldObjectType.ROBOT)) def test_given_world_object_type_detected_then_world_object_type_returns_as_detected(self): self._world_map = self._world_map_service.detect_objects(self.test_image) assert_true(self._world_map.contains(WorldObjectType.ROBOT)) def test_given_world_object_type_not_detected_then_world_object_type_returns_as_not_detected(self): self._world_map = self._world_map_service.detect_objects(self.blank_test_image) assert_false(self._world_map.contains(WorldObjectType.ROBOT))
class TestWorldMapDrawingService(object): TEST_IMAGE_FILE = "../resources/test_data/image_detection/world_mixed/vlcsnap-2016-02-26-18h23m51s955.png" @classmethod def setup_class(cls): cls.test_image = Image.from_file(cls.TEST_IMAGE_FILE) def setup(self): self._world_map_service = WorldMapService(CoordinateFactory()) self._world_map_drawing_service = WorldMapDrawingService() def test_given_world_map_when_drawing_world_map_then_world_map_is_drawn(self): self._world_map = self._world_map_service.detect_objects(self.test_image) self._world_map_drawing_service.draw(self._world_map)
def setup(self): self._world_map_service = WorldMapService(CoordinateFactory()) self._world_map_drawing_service = WorldMapDrawingService()
def setup(self): self._world_map_service = WorldMapService(CoordinateFactory())