Beispiel #1
0
    def test_create(self):
        """
        Test whether overriden 'create' method successfully creates a new pipeline
        with a tree of associated plugins.
        """
        plugin_ds1 = Plugin.objects.get(meta__name=self.plugin_ds_name)
        (meta, tf) = PluginMeta.objects.get_or_create(name="mri_analyze",
                                                      type='ds')
        (plugin_ds2, tf) = Plugin.objects.get_or_create(meta=meta)
        owner = User.objects.get(username=self.username)
        plugin_tree = '[{"plugin_id": ' + str(plugin_ds1.id) + \
                         ', "previous_index": null}, {"plugin_id": ' + \
                         str(plugin_ds2.id) + ', "previous_index": 0}]'
        data = {'name': 'Pipeline2', 'plugin_tree': plugin_tree}

        pipeline_serializer = PipelineSerializer(data=data)
        pipeline_serializer.is_valid(raise_exception=True)
        pipeline_serializer.validated_data['owner'] = owner
        pipeline = pipeline_serializer.create(
            pipeline_serializer.validated_data)
        pipeline_plg_names = [
            plugin.meta.name for plugin in pipeline.plugins.all()
        ]
        self.assertIn(self.plugin_ds_name, pipeline_plg_names)
        self.assertIn("mri_analyze", pipeline_plg_names)
Beispiel #2
0
 def add_pipeline(self, args):
     """
     Add a new pipeline to the system.
     """
     data = {'name': args.name, 'plugin_tree': args.plugintree}
     if args.authors:
         data['authors'] = args.authors
     if args.category:
         data['category'] = args.category
     if args.description:
         data['description'] = args.description
     if args.unlock:
         data['locked'] = False
     pipeline_serializer = PipelineSerializer(data=data)
     pipeline_serializer.is_valid(raise_exception=True)
     owner = User.objects.get(username=args.owner)
     pipeline_serializer.save(owner=owner)
Beispiel #3
0
 def modify_pipeline(self, args):
     """
     Modify an existing pipeline.
     """
     pipeline = self.get_pipeline(args.id)
     data = {}
     if args.name:
         data['name'] = args.name
     if args.authors:
         data['authors'] = args.authors
     if args.category:
         data['category'] = args.category
     if args.description:
         data['description'] = args.description
     if args.unlock:
         data['locked'] = False
     pipeline_serializer = PipelineSerializer(pipeline, data=data)
     pipeline_serializer.is_valid(raise_exception=True)
     pipeline_serializer.save()
    def test_create(self):
        """
        Test whether overriden 'create' method successfully creates a new pipeline
        with a tree of associated plugins.
        """
        plugin_ds1 = Plugin.objects.get(name=self.plugin_ds_name)
        (plugin_ds2, tf) = Plugin.objects.get_or_create(name="mri_analyze", type="ds",
                                                compute_resource=self.compute_resource)
        owner = User.objects.get(username=self.username)
        plugin_id_tree = '[{"plugin_id": ' + str(plugin_ds1.id) + \
                         ', "previous_index": null}, {"plugin_id": ' + \
                         str(plugin_ds2.id) + ', "previous_index": 0}]'
        data = {'name': 'Pipeline2', 'plugin_id_tree': plugin_id_tree}

        pipeline_serializer = PipelineSerializer(data=data)
        pipeline_serializer.is_valid(raise_exception=True)
        pipeline_serializer.validated_data['owner'] = owner
        pipeline = pipeline_serializer.create(pipeline_serializer.validated_data)
        pipeline_plg_names = [plugin.name for plugin in pipeline.plugins.all()]
        self.assertIn(self.plugin_ds_name, pipeline_plg_names)
        self.assertIn("mri_analyze", pipeline_plg_names)