소스 검색

fix(api): change '__all__' error key to 'non_field_errors' for consistency

Peter Thomassen 5 년 전
부모
커밋
d23f16c661
3개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 1
      api/desecapi/serializers.py
  2. 5 5
      api/desecapi/tests/test_rrsets_bulk.py
  3. 6 6
      test/e2e/spec/api_spec.js

+ 1 - 1
api/desecapi/serializers.py

@@ -350,7 +350,7 @@ class RRsetListSerializer(ListSerializer):
                 # see if other rows have the same key
                 if len(indices_by_key[self._key(item)]) > 1:
                     raise serializers.ValidationError({
-                        '__all__': [
+                        'non_field_errors': [
                             'Same subname and type as in position(s) %s, but must be unique.' %
                             ', '.join(map(str, indices_by_key[self._key(item)] - {idx}))
                         ]

+ 5 - 5
api/desecapi/tests/test_rrsets_bulk.py

@@ -93,8 +93,8 @@ class AuthenticatedRRSetBulkTestCase(AuthenticatedRRSetBaseTestCase):
             self.client.bulk_post_rr_sets(domain_name=self.my_empty_domain.name, payload=data),
             status.HTTP_400_BAD_REQUEST,
             [
-                {'__all__': ['Same subname and type as in position(s) 1, but must be unique.']},
-                {'__all__': ['Same subname and type as in position(s) 0, but must be unique.']},
+                {'non_field_errors': ['Same subname and type as in position(s) 1, but must be unique.']},
+                {'non_field_errors': ['Same subname and type as in position(s) 0, but must be unique.']},
                 {},
             ]
         )
@@ -104,10 +104,10 @@ class AuthenticatedRRSetBulkTestCase(AuthenticatedRRSetBaseTestCase):
             self.client.bulk_post_rr_sets(domain_name=self.my_empty_domain.name, payload=data),
             status.HTTP_400_BAD_REQUEST,
             [
-                {'__all__': ['Same subname and type as in position(s) 1, 3, but must be unique.']},
-                {'__all__': ['Same subname and type as in position(s) 0, 3, but must be unique.']},
+                {'non_field_errors': ['Same subname and type as in position(s) 1, 3, but must be unique.']},
+                {'non_field_errors': ['Same subname and type as in position(s) 0, 3, but must be unique.']},
                 {},
-                {'__all__': ['Same subname and type as in position(s) 0, 1, but must be unique.']},
+                {'non_field_errors': ['Same subname and type as in position(s) 0, 1, but must be unique.']},
             ]
         )
 

+ 6 - 6
test/e2e/spec/api_spec.js

@@ -549,8 +549,8 @@ describe("API v1", function () {
 
                         it("gives the right response", function () {
                             expect(response).to.have.json([
-                                {"__all__": ["Same subname and type as in position(s) 1, but must be unique."]},
-                                {"__all__": ["Same subname and type as in position(s) 0, but must be unique."]}
+                                {"non_field_errors": ["Same subname and type as in position(s) 1, but must be unique."]},
+                                {"non_field_errors": ["Same subname and type as in position(s) 0, but must be unique."]}
                             ]);
                             return chakram.wait();
                         });
@@ -780,8 +780,8 @@ describe("API v1", function () {
 
                         it("gives the right response", function () {
                             return expect(response).to.have.json([
-                                { '__all__': [ 'Same subname and type as in position(s) 1, but must be unique.' ] },
-                                { '__all__': [ 'Same subname and type as in position(s) 0, but must be unique.' ] },
+                                { 'non_field_errors': [ 'Same subname and type as in position(s) 1, but must be unique.' ] },
+                                { 'non_field_errors': [ 'Same subname and type as in position(s) 0, but must be unique.' ] },
                             ]);
                         });
 
@@ -1021,8 +1021,8 @@ describe("API v1", function () {
 
                         it("gives the right response", function () {
                             return expect(response).to.have.json([
-                                { '__all__': [ 'Same subname and type as in position(s) 1, but must be unique.' ] },
-                                { '__all__': [ 'Same subname and type as in position(s) 0, but must be unique.' ] },
+                                { 'non_field_errors': [ 'Same subname and type as in position(s) 1, but must be unique.' ] },
+                                { 'non_field_errors': [ 'Same subname and type as in position(s) 0, but must be unique.' ] },
                             ]);
                         });