def test_successful(self, mock_store): """Tests calling RecipeDefinition.validate_data() successfully.""" definition = { 'version': '1.0', 'input_data': [{ 'name': 'Recipe Input', 'type': 'file', 'media_types': ['text/plain'], }], 'jobs': [{ 'name': 'Job 1', 'job_type': { 'name': self.job_type_1.name, 'version': self.job_type_1.version, }, 'recipe_inputs': [{ 'recipe_input': 'Recipe Input', 'job_input': self.input_name_1, }], }, { 'name': 'Job 2', 'job_type': { 'name': self.job_type_2.name, 'version': self.job_type_2.version, }, 'dependencies': [{ 'name': 'Job 1', 'connections': [{ 'output': self.output_name_1, 'input': self.input_name_2, }], }], }], } recipe = RecipeDefinition(definition) recipe.validate_job_interfaces() data = { 'version': '1.0', 'input_data': [{ 'name': 'Recipe Input', 'file_id': self.file_1.id, }], 'workspace_id': 1, } recipe_data = LegacyRecipeData(data) # No exception is success recipe.validate_data(recipe_data)
def test_successful_no_workspace(self, mock_store): """Tests calling RecipeDefinition.validate_data() successfully with no workspace.""" definition = { 'version': '1.0', 'input_data': [{ 'name': 'Recipe Input', 'type': 'file', 'media_types': ['text/plain'], }], 'jobs': [{ 'name': 'Job 3', 'job_type': { 'name': self.job_type_3.name, 'version': self.job_type_3.version, }, 'recipe_inputs': [{ 'recipe_input': 'Recipe Input', 'job_input': self.input_name_3, }], }], } recipe = RecipeDefinition(definition) recipe.validate_job_interfaces() data = { 'version': '1.0', 'input_data': [{ 'name': 'Recipe Input', 'file_id': self.file_1.id, }], } recipe_data = LegacyRecipeData(data) # No exception is success recipe.validate_data(recipe_data)