Skip to content

Commit

Permalink
Make tests pass on DRFv3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xychu committed Dec 9, 2015
1 parent 1e92a8e commit e04d869
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pdc/apps/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def test_create_existing_label(self):
url = reverse('label-list')
response = self.client.post(url, format='json', data=self.args_label1)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data, {"name": ["This field must be unique."]})
self.assertIn(response.data, [{"name": ["This field must be unique."]}, # DRF v3.2 its own UniqueValidator,
{"name": ["Label with this name already exists."]}]) # v3.3 use Django's default.

def test_put_update(self):
url = reverse('label-detail', kwargs={'pk': 1})
Expand Down
4 changes: 2 additions & 2 deletions pdc/apps/component/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,12 @@ def create(self, request, *args, **kwargs):
if not serializer.is_valid():
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

headers = self.get_success_headers(serializer.data)
if created:
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
else:
return Response(serializer.data, status=status.HTTP_200_OK, headers=headers)
return Response(serializer.data, status=status.HTTP_200_OK)

def destroy(self, request, *args, **kwargs):
"""
Expand Down
4 changes: 2 additions & 2 deletions pdc/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

'DEFAULT_METADATA_CLASS': 'contrib.bulk_operations.metadata.BulkMetadata',

'PAGINATE_BY': 20,

'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'pdc.apps.common.renderers.ReadOnlyBrowsableAPIRenderer',
),

'EXCEPTION_HANDLER': 'pdc.apps.common.handlers.exception_handler',

'DEFAULT_PAGINATION_CLASS': 'pdc.apps.common.pagination.AutoDetectedPageNumberPagination',

'NON_FIELD_ERRORS_KEY': 'detail',
}
2 changes: 1 addition & 1 deletion requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://github.com/release-engineering/productmd/archive/master.tar.gz#egg=produ
# requires: openldap-devel
python-ldap
# django rest framework
djangorestframework<3.3
djangorestframework
Markdown
django-filter==0.9.2
django-mptt>=0.7.1
Expand Down

1 comment on commit e04d869

@ycheng-aa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.