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})
def setUp(self): super().setUp() self.entity = Entity.objects.create(name="Test entity", contributor=self.contributor) process = Process.objects.create( name="Test process", contributor=self.contributor, output_schema=[ {'name': 'foo', 'label': 'Foo', 'group': [ {'name': 'bar', 'label': 'Bar', 'type': 'basic:integer:'}, {'name': 'hello', 'label': 'Hello', 'type': 'basic:string:'}, ]}, {'name': 'another', 'label': 'Another', 'type': 'basic:integer:'}, ] ) data_output = { 'foo': { 'bar': 42, 'hello': 'world', }, 'another': 3, } self.data_output = data_output self.data = Data.objects.create(name="Test data", contributor=self.contributor, process=process, output=data_output) self.data_2 = Data.objects.create(name="Test data 2", contributor=self.contributor, process=process, output=data_output) self.entity.data.add(self.data) self.entity.data.add(self.data_2) self.entity_viewset = EntityViewSet.as_view(actions={'get': 'list'})
def setUp(self): super().setUp() self.viewset = EntityViewSet.as_view(actions={ "get": "list", }) self.descriptor_schema = DescriptorSchema.objects.create( slug="sample", contributor=self.contributor, schema=[{ "label": "General", "name": "general", "group": [ { "name": "species", "type": "basic:string:", "label": "Species", }, ], }], ) self.entities = [ Entity.objects.create( name="Test entity 1", contributor=self.contributor, descriptor_schema=self.descriptor_schema, descriptor={"general": { "species": "H**o Sapiens" }}, ), Entity.objects.create( name="Test entity 2", contributor=self.contributor, descriptor_schema=self.descriptor_schema, descriptor={"general": { "species": "Mus musculus" }}, ), ]
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.collections.add(self.collection2) 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})
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})
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})