def test_split_geom_raise_grid_service_error_when_task_not_usable(self): if self.skip_tests: return with self.assertRaises(SplitServiceError): task_stub = Task() task_stub.is_square = True SplitService._create_split_tasks("foo", "bar", "dum", task_stub)
def test_per_task_instructions_with_underscores_formatted_correctly(self): test_task = Task() test_task.x = 1 test_task.y = 2 test_task.zoom = 3 test_task.is_square = True # Act instructions = test_task.format_per_task_instructions( "Test Url is http://test.com/{x}_{y}_{z}") # Assert self.assertEqual(instructions, "Test Url is http://test.com/1_2_3")
def test_split_task_helper( self, mock_task_get, mock_task_get_max_task_id_for_project, mock_task_create, mock_task_delete, mock_project_get, mock_project_save, mock_project_tasks, mock_instructions, ): if self.skip_tests: return # arrange task_stub = Task() task_stub.id = 1 task_stub.project_id = 1 task_stub.task_status = 1 task_stub.locked_by = 1234 task_stub.lock_holder = 1234 task_stub.is_square = True task_stub.x = 16856 task_stub.y = 17050 task_stub.zoom = 15 task_stub.geometry = shape.from_shape( Polygon( [ (5.1855468740711421, 7.2970875628719796), (5.1855468740711421, 7.3079847788619219), (5.1965332021941588, 7.3079847788619219), (5.1965332021941588, 7.2970875628719796), (5.1855468740711421, 7.2970875628719796), ] ) ) mock_task_get.return_value = task_stub mock_task_get_max_task_id_for_project.return_value = 1 mock_project_get.return_value = Project() mock_project_tasks.return_value = [task_stub] splitTaskDTO = SplitTaskDTO() splitTaskDTO.user_id = 1234 splitTaskDTO.project_id = 1 splitTaskDTO.task_id = 1 # act result = SplitService.split_task(splitTaskDTO) # assert self.assertEqual(4, len(result.tasks))
def test_per_task_instructions_formatted_correctly(self): # Arrange test_task = Task() test_task.x = 1 test_task.y = 2 test_task.zoom = 3 test_task.is_square = True # Act instructions = test_task.format_per_task_instructions( "Test Url is http://test.com/{x}/{y}/{z}") # Assert self.assertEqual(instructions, "Test Url is http://test.com/1/2/3")
def test_per_task_instructions_returns_instructions_when_no_dynamic_url_and_task_not_splittable( self, ): # Arrange test_task = Task() test_task.x = 1 test_task.y = 2 test_task.zoom = 3 test_task.is_square = False # Act instructions = test_task.format_per_task_instructions("Use map box") # Assert self.assertEqual(instructions, "Use map box")
def test_split_geom_returns_split_geometries(self): # arrange x = 2021 y = 2798 zoom = 12 task_stub = Task() task_stub.is_square = True expected = geojson.loads(json.dumps(get_canned_json("split_task.json"))) # act result = SplitService._create_split_tasks(x, y, zoom, task_stub) # assert self.assertEqual(str(expected), str(result))
def test_per_task_instructions_returns_instructions_with_extra_properties( self): # Arrange test_task = Task() test_task.extra_properties = '{"foo": "bar"}' test_task.x = 1 test_task.y = 2 test_task.zoom = 3 test_task.is_square = True # Act instructions = test_task.format_per_task_instructions( "Foo is replaced by {foo}") # Assert self.assertEqual(instructions, "Foo is replaced by bar")