Skip to content

Commit

Permalink
🎨 [#339] Replaced ._headers with .headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ErhanCitil committed Jun 13, 2023
1 parent 7f6d67f commit 7eb2277
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/objects/tests/v1/test_auth_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_retrieve_without_query(self):
},
)
self.assertEqual(
set(response._headers["x-unauthorized-fields"][1].split(",")),
set(response.headers["x-unauthorized-fields"][1].split(",")),
{
"uuid",
"record__data__name",
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_retrieve_with_query_fields(self):
"record": {"data": {"name": record.data["name"]}},
},
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_retrieve_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_retrieve_query_fields_not_allowed(self):
},
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1], "record__data__desc"
response.headers["x-unauthorized-fields"][1], "record__data__desc"
)

def test_retrieve_no_allowed_fields(self):
Expand All @@ -160,7 +160,7 @@ def test_retrieve_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), {})
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class ListAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_list_without_query_different_object_types(self):
],
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1],
response.headers["x-unauthorized-fields"][1],
f"{self.other_object_type.url}(1)=type; {self.object_type.url}(1)=uuid",
)

Expand Down Expand Up @@ -283,7 +283,7 @@ def test_list_with_query_fields(self):
},
],
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_list_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -376,7 +376,7 @@ def test_list_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), [{}, {}])
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class SearchAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down
14 changes: 7 additions & 7 deletions src/objects/tests/v2/test_auth_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_retrieve_without_query(self):
},
)
self.assertEqual(
set(response._headers["x-unauthorized-fields"][1].split(",")),
set(response.headers["x-unauthorized-fields"][1].split(",")),
{
"uuid",
"record__data__name",
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_retrieve_with_query_fields(self):
"record": {"data": {"name": record.data["name"]}},
},
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_retrieve_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_retrieve_query_fields_not_allowed(self):
},
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1], "record__data__desc"
response.headers["x-unauthorized-fields"][1], "record__data__desc"
)

def test_retrieve_no_allowed_fields(self):
Expand All @@ -160,7 +160,7 @@ def test_retrieve_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), {})
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class ListAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_list_without_query_different_object_types(self):
],
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1],
response.headers["x-unauthorized-fields"][1],
f"{self.other_object_type.url}(1)=type; {self.object_type.url}(1)=uuid",
)

Expand Down Expand Up @@ -283,7 +283,7 @@ def test_list_with_query_fields(self):
},
],
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_list_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_list_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["results"], [{}, {}])
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class SearchAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down
2 changes: 1 addition & 1 deletion src/objects/tests/v2/test_notifications_kanaal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test import override_settings

from rest_framework.test import APITestCase
from vng_api_common.notifications.kanalen import Kanaal
from notifications_api_common.kanalen import Kanaal

from objects.core.models import Object

Expand Down
1 change: 1 addition & 0 deletions src/objects/tests/v2/test_notifications_send.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import patch

from django.test import override_settings
from django.test import TestCase

import requests_mock
from django_capture_on_commit_callbacks import capture_on_commit_callbacks
Expand Down

0 comments on commit 7eb2277

Please sign in to comment.