Skip to content

Commit

Permalink
Source/Collection version export 208 if doesn't exists and processing
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Mar 2, 2021
1 parent f3cf2ee commit f9124cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/common/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
response['Last-Updated-Timezone'] = settings.TIME_ZONE_PLACE
return response

if version.is_processing:
return Response(status=status.HTTP_208_ALREADY_REPORTED)

return Response(status=status.HTTP_204_NO_CONTENT)

def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down
16 changes: 16 additions & 0 deletions core/integration_tests/tests_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,22 @@ def test_get_200(self, s3_exists_mock, s3_url_for_mock):
s3_exists_mock.assert_called_once_with("username/source1_v1.{}.zip".format(self.v1_updated_at))
s3_url_for_mock.assert_called_once_with("username/source1_v1.{}.zip".format(self.v1_updated_at))

@patch('core.common.services.S3.exists')
def test_get_208(self, s3_exists_mock):
s3_exists_mock.return_value = False
self.source_v1._background_process_ids = ['some-task-id'] # pylint: disable=protected-access
self.source_v1.save()
self.assertTrue(self.source_v1.is_processing)

response = self.client.get(
'/sources/source1/v1/export/',
HTTP_AUTHORIZATION='Token ' + self.token,
format='json'
)

self.assertEqual(response.status_code, 208)
s3_exists_mock.assert_called_once_with("username/source1_v1.{}.zip".format(self.v1_updated_at))

def test_get_405(self):
response = self.client.get(
'/sources/source1/HEAD/export/',
Expand Down

0 comments on commit f9124cf

Please sign in to comment.