def test_validate_validates_all_defaults_can_be_defined_if_pipeline_unlocked( self): """ Test whether overriden validate method validates that all parameter defaults for the pipeline can be defined if the pipeline is unlocked. """ plugin_ds = Plugin.objects.get(name=self.plugin_ds_name) # add a parameter without a default PluginParameter.objects.get_or_create(plugin=plugin_ds, name='dummyFloat', type='float', optional=False) owner = User.objects.get(username=self.username) plugin_tree = { 'root_index': 0, 'tree': [{ 'plugin_id': plugin_ds.id, 'child_indices': [], 'plugin_parameter_defaults': [] }] } data = { 'name': 'Pipeline2', 'owner': owner, 'plugin_tree': plugin_tree, 'locked': False } pipeline_serializer = PipelineSerializer(data=data) with self.assertRaises(serializers.ValidationError): pipeline_serializer.validate(data)
def test_validate_validates_required_fields_on_create(self): """ Test whether overriden validate method validates that 'plugin_tree' field must be provided when creating a new pipeline. """ owner = User.objects.get(username=self.username) data = {'name': 'Pipeline2', 'owner': owner} pipeline_serializer = PipelineSerializer(data=data) with self.assertRaises(serializers.ValidationError): pipeline_serializer.validate(data)
def test_validate_validates_required_fields_on_create(self): """ Test whether overriden validate method validates that at least one of the fields 'plugin_id_tree' or 'plugin_inst_id' must be provided when creating a new pipeline. """ owner = User.objects.get(username=self.username) data = {'name': 'Pipeline2', 'owner': owner} pipeline_serializer = PipelineSerializer(data=data) with self.assertRaises(serializers.ValidationError): pipeline_serializer.validate(data)