コード例 #1
0
 def test_artifact_list_superuser(self):
     """Superusers should be able to access a list of all artifacts."""
     self._login(self.superuser)
     response = self.client.get(reverse('usertaskartifact-list'))
     assert response.status_code == 200
     serializer = ArtifactSerializer(self.artifact,
                                     context=_context(response))
     assert _data(response) == [serializer.data]
コード例 #2
0
 def test_artifact_list(self):
     """
     Users should be able to access a list of their tasks' artifacts.
     """
     response = self.client.get(reverse('usertaskartifact-list'))
     assert response.status_code == 200
     serializer = ArtifactSerializer(self.artifact, context=_context(response))
     assert _data(response)['results'] == [serializer.data]
コード例 #3
0
 def test_artifact_detail(self):
     """
     Users should be able to access artifacts for tasks they triggered.
     """
     response = self.client.get(reverse('usertaskartifact-detail', args=[self.artifact.uuid]))
     assert response.status_code == 200
     serializer = ArtifactSerializer(self.artifact, context=_context(response))
     assert _data(response) == serializer.data
コード例 #4
0
 def test_artifact_detail_superuser(self):
     """Superusers should be able to access artifacts for all tasks."""
     self._login(self.superuser)
     response = self.client.get(
         reverse('usertaskartifact-detail', args=[self.artifact.uuid]))
     assert response.status_code == 200
     serializer = ArtifactSerializer(self.artifact,
                                     context=_context(response))
     assert _data(response) == serializer.data
コード例 #5
0
 def test_url(self):
     """The serializer should handle URL artifacts correctly."""
     artifact = UserTaskArtifact.objects.create(
         status=self.status, url='http://www.example.com/output/3/')
     expected = {
         'status': 'http://testserver/tasks/{}/'.format(self.status.uuid),
         'name': 'Output',
         'created': _format(artifact.created),
         'modified': _format(artifact.modified),
         'file': '',
         'text': '',
         'url': artifact.url,
     }
     request = APIRequestFactory().get(
         reverse('usertaskartifact-detail', args=[artifact.uuid]))
     serializer = ArtifactSerializer(artifact, context={'request': request})
     assert serializer.data == expected
コード例 #6
0
 def test_text(self):
     """The serializer should handle text block artifacts correctly."""
     artifact = UserTaskArtifact.objects.create(
         status=self.status, text='Got your output right here.')
     expected = {
         'status': 'http://testserver/tasks/{}/'.format(self.status.uuid),
         'name': 'Output',
         'created': _format(artifact.created),
         'modified': _format(artifact.modified),
         'file': '',
         'text': artifact.text,
         'url': '',
     }
     request = APIRequestFactory().get(
         reverse('usertaskartifact-detail', args=[artifact.uuid]))
     serializer = ArtifactSerializer(artifact, context={'request': request})
     assert serializer.data == expected
コード例 #7
0
 def test_file(self):
     """The serializer should handle file artifacts correctly."""
     uploaded_file = SimpleUploadedFile('filename.txt',
                                        b'Content of the file')
     artifact = UserTaskArtifact.objects.create(status=self.status,
                                                file=uploaded_file)
     expected = {
         'status': 'http://testserver/tasks/{}/'.format(self.status.uuid),
         'name': 'Output',
         'created': _format(artifact.created),
         'modified': _format(artifact.modified),
         'file': artifact.file.url,
         'text': '',
         'url': '',
     }
     request = APIRequestFactory().get(
         reverse('usertaskartifact-detail', args=[artifact.uuid]))
     serializer = ArtifactSerializer(artifact, context={'request': request})
     assert serializer.data == expected