Skip to content

Commit

Permalink
Change non_field_errors to detail.
Browse files Browse the repository at this point in the history
JIRA: PDC-957
  • Loading branch information
simozhan committed Sep 10, 2015
1 parent ea6a8aa commit a4b1798
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pdc/apps/compose/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def test_update_can_not_link_to_same_release(self):
{'linked_releases': ['release-1.0']},
format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn('non_field_errors', response.data)
self.assertIn('detail', response.data)

def test_update_can_not_link_to_same_release_twice(self):
response = self.client.patch(reverse('compose-detail', args=['compose-1']),
Expand Down
2 changes: 1 addition & 1 deletion pdc/apps/contact/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def test_create_with_exists_value(self):
response = self.client.post(url, data, format='json')

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data, {"non_field_errors": ["The fields (\'contact\', \'contact_role\') must make a unique set."]})
self.assertEqual(response.data, {"detail": ["The fields (\'contact\', \'contact_role\') must make a unique set."]})
self.assertNumChanges([])

def test_create_with_bad_type(self):
Expand Down
10 changes: 5 additions & 5 deletions pdc/apps/repository/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_deserialize_invalid_from_custom_validator(self):
serializer = serializers.RepoSerializer(data=self.data)
self.assertFalse(serializer.is_valid())
self.assertEqual(serializer.errors,
{'non_field_errors': ["Missing 'debug' in repo name 'test_repo_2'"]})
{'detail': ["Missing 'debug' in repo name 'test_repo_2'"]})

def test_deserialize_invalid_shadow(self):
self.data['shadow'] = 'very shadow'
Expand All @@ -81,7 +81,7 @@ def test_deserialize_duplicit(self):
serializer = serializers.RepoSerializer(data=self.fixture_data)
self.assertFalse(serializer.is_valid())
self.assertEqual(serializer.errors,
{'non_field_errors': [
{'detail': [
# Following is a single string
'Repo with this Variant arch, Service, Repo family, Content format, '
'Content category, Name and Shadow already exists.']})
Expand All @@ -104,9 +104,9 @@ def test_deserialize_with_bad_indirectly_related_field_value(self):
self.data[key] = 'foo'
serializer = serializers.RepoSerializer(data=self.data)
self.assertFalse(serializer.is_valid())
self.assertIn('non_field_errors', serializer.errors)
self.assertEqual(len(serializer.errors['non_field_errors']), 1)
self.assertRegexpMatches(serializer.errors['non_field_errors'][0],
self.assertIn('detail', serializer.errors)
self.assertEqual(len(serializer.errors['detail']), 1)
self.assertRegexpMatches(serializer.errors['detail'][0],
r'^No VariantArch .*')
self.data[key] = old_val

Expand Down
3 changes: 3 additions & 0 deletions pdc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
'EXCEPTION_HANDLER': 'pdc.apps.common.handlers.exception_handler',

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

'NON_FIELD_ERRORS_KEY': 'detail',
}

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -310,6 +312,7 @@
}
}


# Attempts to import server specific settings.
# Note that all server specific settings should go to 'settings_local.py'
try:
Expand Down
4 changes: 3 additions & 1 deletion pdc/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@
'pdc.apps.common.renderers.ReadOnlyBrowsableAPIRenderer',
),

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

'NON_FIELD_ERRORS_KEY': 'detail',
}

0 comments on commit a4b1798

Please sign in to comment.