示例#1
0
    def setUp(self):
        super(EntityViewSetTest, self).setUp()

        self.collection = Collection.objects.create(
            name="Test Collection", contributor=self.contributor)
        self.entity = Entity.objects.create(name="Test entity",
                                            contributor=self.contributor)
        process = Process.objects.create(name="Test process",
                                         contributor=self.contributor)
        self.data = Data.objects.create(name="Test data",
                                        contributor=self.contributor,
                                        process=process)
        self.data_2 = Data.objects.create(name="Test data 2",
                                          contributor=self.contributor,
                                          process=process)

        # another Data object to make sure that other objects are not processed
        Data.objects.create(name="Dummy data",
                            contributor=self.contributor,
                            process=process)

        self.entity.data.add(self.data)

        assign_perm('add_collection', self.contributor, self.collection)
        assign_perm('add_entity', self.contributor, self.entity)

        self.entityviewset = EntityViewSet()
示例#2
0
    def setUp(self):
        super(EntityViewSetTest, self).setUp()

        self.collection = Collection.objects.create(name="Test Collection", contributor=self.contributor)
        self.entity = Entity.objects.create(name="Test entity", contributor=self.contributor)
        process = Process.objects.create(name="Test process", contributor=self.contributor)
        self.data = Data.objects.create(name="Test data", contributor=self.contributor, process=process)
        self.data_2 = Data.objects.create(name="Test data 2", contributor=self.contributor, process=process)

        # another Data object to make sure that other objects are not processed
        Data.objects.create(name="Dummy data", contributor=self.contributor, process=process)

        self.entity.data.add(self.data)

        assign_perm('add_collection', self.contributor, self.collection)
        assign_perm('add_entity', self.contributor, self.entity)

        self.entityviewset = EntityViewSet()

        self.entity_detail_viewset = EntityViewSet.as_view(actions={
            'get': 'retrieve',
            'put': 'update',
            'patch': 'partial_update',
            'delete': 'destroy',
        })
        self.entity_list_viewset = EntityViewSet.as_view(actions={
            'get': 'list',
            'post': 'create',
        })

        self.detail_url = lambda pk: reverse('resolwe-api:entity-detail', kwargs={'pk': pk})
示例#3
0
    def setUp(self):
        super().setUp()

        self.collection = Collection.objects.create(
            name="Test Collection", contributor=self.contributor)
        self.collection2 = Collection.objects.create(
            name="Test Collection 2", contributor=self.contributor)
        self.entity = Entity.objects.create(name="Test entity",
                                            contributor=self.contributor)
        process = Process.objects.create(name="Test process",
                                         contributor=self.contributor)
        self.data = Data.objects.create(
            name="Test data",
            contributor=self.contributor,
            process=process,
            status=Data.STATUS_DONE,
        )
        data_location = DataLocation.objects.create(subpath="")
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(self.data)
        self.data_2 = Data.objects.create(
            name="Test data 2",
            contributor=self.contributor,
            process=process,
            status=Data.STATUS_DONE,
        )
        data_location = DataLocation.objects.create(subpath="")
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(self.data_2)

        # another Data object to make sure that other objects are not processed
        data = Data.objects.create(name="Dummy data",
                                   contributor=self.contributor,
                                   process=process)
        data_location = DataLocation.objects.create(subpath="")
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(data)

        self.entity.data.add(self.data)
        self.entity.collection = self.collection2
        self.entity.save()

        assign_perm("edit_collection", self.contributor, self.collection)
        assign_perm("edit_entity", self.contributor, self.entity)
        assign_perm("view_collection", self.contributor, self.collection)
        assign_perm("view_collection", self.contributor, self.collection2)
        assign_perm("view_entity", self.contributor, self.entity)

        self.entityviewset = EntityViewSet()

        self.duplicate_viewset = EntityViewSet.as_view(actions={
            "post": "duplicate",
        })
        self.move_to_collection_viewset = EntityViewSet.as_view(
            actions={
                "post": "move_to_collection",
            })
        self.entity_detail_viewset = EntityViewSet.as_view(
            actions={
                "get": "retrieve",
                "put": "update",
                "patch": "partial_update",
                "delete": "destroy",
            })
        self.entity_list_viewset = EntityViewSet.as_view(actions={
            "get": "list",
            "post": "create",
        })

        self.detail_url = lambda pk: reverse("resolwe-api:entity-detail",
                                             kwargs={"pk": pk})
示例#4
0
    def setUp(self):
        super().setUp()

        self.collection = Collection.objects.create(
            name="Test Collection", contributor=self.contributor)
        self.collection2 = Collection.objects.create(
            name="Test Collection 2", contributor=self.contributor)
        self.entity = Entity.objects.create(name="Test entity",
                                            contributor=self.contributor)
        process = Process.objects.create(name="Test process",
                                         contributor=self.contributor)
        self.data = Data.objects.create(name="Test data",
                                        contributor=self.contributor,
                                        process=process,
                                        status=Data.STATUS_DONE)
        data_location = DataLocation.objects.create(subpath='')
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(self.data)
        self.data_2 = Data.objects.create(name="Test data 2",
                                          contributor=self.contributor,
                                          process=process,
                                          status=Data.STATUS_DONE)
        data_location = DataLocation.objects.create(subpath='')
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(self.data_2)

        # another Data object to make sure that other objects are not processed
        data = Data.objects.create(name="Dummy data",
                                   contributor=self.contributor,
                                   process=process)
        data_location = DataLocation.objects.create(subpath='')
        data_location.subpath = str(data_location.id)
        data_location.save()
        data_location.data.add(data)

        self.entity.data.add(self.data)
        self.entity.collection = self.collection2
        self.entity.save()

        assign_perm('add_collection', self.contributor, self.collection)
        assign_perm('add_entity', self.contributor, self.entity)
        assign_perm('view_collection', self.contributor, self.collection)
        assign_perm('view_collection', self.contributor, self.collection2)
        assign_perm('view_entity', self.contributor, self.entity)

        self.entityviewset = EntityViewSet()

        self.duplicate_viewset = EntityViewSet.as_view(actions={
            'post': 'duplicate',
        })
        self.move_to_collection_viewset = EntityViewSet.as_view(
            actions={
                'post': 'move_to_collection',
            })
        self.entity_detail_viewset = EntityViewSet.as_view(
            actions={
                'get': 'retrieve',
                'put': 'update',
                'patch': 'partial_update',
                'delete': 'destroy',
            })
        self.entity_list_viewset = EntityViewSet.as_view(actions={
            'get': 'list',
            'post': 'create',
        })

        self.detail_url = lambda pk: reverse('resolwe-api:entity-detail',
                                             kwargs={'pk': pk})