예제 #1
0
    def test_successful(self):
        '''Tests calling IngestTriggerRuleConfiguration.validate() successfully'''

        workspace_name = 'Test_Workspace'
        storage_utils.create_workspace(name=workspace_name)
        json_str = '{"condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "%s"}}' % workspace_name
        rule = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(json_str))

        rule.validate()
예제 #2
0
    def test_media_type_warning(self):
        '''Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_job() with a warning for a mis-matched media type'''

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        interface_json_str = '{"version": "1.0", "command": "my cmd", "command_arguments": "cmd args", "input_data": [{"name": "my_input", "type": "file", "media_types": ["application/json"]}], "output_data": [{"name": "my_output", "type": "file"}]}'
        job_interface = JobInterface(json.loads(interface_json_str))

        warnings = rule_config.validate_trigger_for_job(job_interface)

        self.assertEqual(len(warnings), 1)
예제 #3
0
    def test_media_type_warning(self):
        '''Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_recipe() with a warning for a mis-matched media type'''

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        definition_json_str = '{"version": "1.0", "input_data": [{"name": "my_input", "type": "file", "media_types": ["application/json"]}], "jobs": [{"name": "my_job", "job_type": {"name": "test_job", "version": "1.0"}}]}'
        recipe_definition = RecipeDefinition(json.loads(definition_json_str))

        warnings = rule_config.validate_trigger_for_recipe(recipe_definition)

        self.assertEqual(len(warnings), 1)
예제 #4
0
    def test_successful(self):
        """Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_job() successfully with no warnings"""

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        interface_json_str = '{"version": "1.0", "command": "my cmd", "command_arguments": "cmd args", "input_data": [{"name": "my_input", "type": "file", "media_types": ["text/plain", "application/json"]}], "output_data": [{"name": "my_output", "type": "file"}]}'
        job_interface = JobInterface(json.loads(interface_json_str))

        warnings = rule_config.validate_trigger_for_job(job_interface)

        self.assertListEqual(warnings, [])
예제 #5
0
    def test_successful(self):
        """Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_recipe() successfully with no warnings"""

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        definition_json_str = '{"version": "1.0", "input_data": [{"name": "my_input", "type": "file", "media_types": ["text/plain", "application/json"]}], "jobs": [{"name": "my_job", "job_type": {"name": "test_job", "version": "1.0"}}]}'
        recipe_definition = RecipeDefinition(json.loads(definition_json_str))

        warnings = rule_config.validate_trigger_for_recipe(recipe_definition)

        self.assertListEqual(warnings, [])
예제 #6
0
    def test_successful(self):
        """Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_recipe() successfully with no warnings"""

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE,
                                                     json.loads(rule_json_str))

        definition_json_str = '{"version": "1.0", "input_data": [{"name": "my_input", "type": "file", "media_types": ["text/plain", "application/json"]}], "jobs": [{"name": "my_job", "job_type": {"name": "test_job", "version": "1.0"}}]}'
        recipe_definition = RecipeDefinition(json.loads(definition_json_str))

        warnings = rule_config.validate_trigger_for_recipe(recipe_definition)

        self.assertListEqual(warnings, [])
예제 #7
0
    def test_bad_workspace(self):
        """Tests calling IngestTriggerRuleConfiguration.validate() with a bad workspace"""

        json_str = '{"condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "BAD_WORKSPACE"}}'
        rule = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(json_str))

        self.assertRaises(InvalidTriggerRule, rule.validate)
예제 #8
0
    def test_bad_input_name(self):
        """Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_job() with a bad input name"""

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        interface_json_str = '{"version": "1.0", "command": "my cmd", "command_arguments": "cmd args", "input_data": [{"name": "different_input_name", "type": "file", "media_types": ["text/plain", "application/json"]}], "output_data": [{"name": "my_output", "type": "file"}]}'
        job_interface = JobInterface(json.loads(interface_json_str))

        self.assertRaises(InvalidConnection, rule_config.validate_trigger_for_job, job_interface)
예제 #9
0
    def test_bad_input_name(self):
        """Tests calling IngestTriggerRuleConfiguration.validate_trigger_for_recipe() with a bad input name"""

        rule_json_str = '{"version": "1.0", "condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        rule_config = IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(rule_json_str))

        definition_json_str = '{"version": "1.0", "input_data": [{"name": "different_input_name", "type": "file", "media_types": ["text/plain", "application/json"]}], "jobs": [{"name": "my_job", "job_type": {"name": "test_job", "version": "1.0"}}]}'
        recipe_definition = RecipeDefinition(json.loads(definition_json_str))

        self.assertRaises(InvalidRecipeConnection, rule_config.validate_trigger_for_recipe, recipe_definition)
예제 #10
0
    def test_successful(self):
        """Tests creating a IngestTriggerRuleConfiguration with valid configuration"""

        json_str = '{"condition": {"media_type": "text/plain", "data_types": ["A", "B"]}, "data": {"input_data_name": "my_input", "workspace_name": "my_workspace"}}'
        IngestTriggerRuleConfiguration(INGEST_TYPE, json.loads(json_str))
예제 #11
0
    def create_configuration(self, config_dict):
        """See :meth:`trigger.handler.TriggerRuleHandler.create_configuration`
        """

        return IngestTriggerRuleConfiguration(INGEST_TYPE, config_dict)