示例#1
0
 def test_validate_plugin_tree_raises_validation_error_if_validate_tree_raises_value_error(
         self):
     """
     Test whether overriden validate_plugin_tree method raises ValidationError if
     internal call to validate_tree method raises ValueError exception.
     """
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     plugin_ds = Plugin.objects.get(name=self.plugin_ds_name)
     tree = '[{"plugin_id": ' + str(
         plugin_ds.id) + ', "previous_index": null}]'
     tree_dict = {
         'root_index': 0,
         'tree': [{
             "plugin_id": plugin_ds.id,
             "child_indices": []
         }]
     }
     with mock.patch(
             'pipelines.serializers.PipelineSerializer.validate_tree'
     ) as validate_tree_mock:
         validate_tree_mock.side_effect = ValueError
         with self.assertRaises(serializers.ValidationError):
             pipeline_serializer.validate_plugin_tree(tree)
             validate_tree_mock.assert_called_with(tree_dict)
示例#2
0
 def test_validate_plugin_tree_does_not_contain_empty_list(self):
     """
     Test whether overriden validate_plugin_tree method validates that the plugin
     tree is not an empty list.
     """
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     tree = '[]'
     with self.assertRaises(serializers.ValidationError):
         pipeline_serializer.validate_plugin_tree(tree)
示例#3
0
 def test_validate_plugin_tree_is_json_string(self):
     """
     Test whether overriden validate_plugin_tree method validates that the plugin
     tree string is a proper JSON string.
     """
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     tree = '[{plugin_id: 8, "previous_index": null}]'
     with self.assertRaises(serializers.ValidationError):
         pipeline_serializer.validate_plugin_tree(tree)
示例#4
0
 def test_validate_plugin_tree_plugins_exist_and_not_fs(self):
     """
     Test whether overriden validate_plugin_tree method validates that the plugin
     tree contains existing plugins that are not of type 'fs'.
     """
     plugin_fs = Plugin.objects.get(meta__name=self.plugin_fs_name)
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     tree = '[{"plugin_id": ' + str(plugin_fs.id + 100) + ', "previous_index": null}]'
     with self.assertRaises(serializers.ValidationError):
         pipeline_serializer.validate_plugin_tree(tree)
     tree = '[{"plugin_id": ' + str(plugin_fs.id) + ', "previous_index": null}]'
     with self.assertRaises(serializers.ValidationError):
         pipeline_serializer.validate_plugin_tree(tree)
示例#5
0
 def test_validate_plugin_tree_has_plugin_name_and_plugin_version_or_plugin_id(
         self):
     """
     Test whether overriden validate_plugin_tree method validates that each
     dictionary/node of the plugin tree contains properties plugin_id or plugin_name
     and plugin_version.
     """
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     tree = '[{"previous_index": null}]'
     with self.assertRaises(serializers.ValidationError):
         pipeline_serializer.validate_plugin_tree(tree)
         tree = '[{"plugin_name": "test", "previous_index": null}]'
         pipeline_serializer.validate_plugin_tree(tree)
示例#6
0
 def test_validate_plugin_tree_raises_validation_error_if_get_tree_raises_value_error(self):
     """
     Test whether overriden validate_plugin_tree method raises ValidationError if
     internal call to get_tree method raises ValueError exception.
     """
     pipeline = Pipeline.objects.get(name=self.pipeline_name)
     pipeline_serializer = PipelineSerializer(pipeline)
     plugin_ds = Plugin.objects.get(meta__name=self.plugin_ds_name)
     tree = '[{"plugin_id": ' + str(plugin_ds.id) + ', "previous_index": null}]'
     with mock.patch('pipelines.serializers.PipelineSerializer.get_tree') as get_tree_mock:
         get_tree_mock.side_effect = ValueError
         with self.assertRaises(serializers.ValidationError):
             pipeline_serializer.validate_plugin_tree(tree)
         get_tree_mock.assert_called_with([{"plugin_id": plugin_ds.id,
                                            "plugin_parameter_defaults": [],
                                            "previous_index": None}])