33
44from public_api .version_02 .views .base import BaseNestedAPITimeSeriesViewV2
55
6+
67class TestNestedTimeSeriesView (BaseNestedAPITimeSeriesViewV2 ):
78 """
89 Minimal concrete implementation so BaseNestedAPITimeSeriesView can be instantiated
@@ -13,6 +14,7 @@ class TestNestedTimeSeriesView(BaseNestedAPITimeSeriesViewV2):
1314
1415 serializer_class = mock .MagicMock
1516
17+
1618class TestBaseNestedAPITimeSeriesViewV2 :
1719 def test_raises_error_for_lookup_field_property (self ):
1820 """
@@ -42,20 +44,23 @@ def test_raises_error_for_serializer_class_property(self):
4244 with pytest .raises (NotImplementedError ):
4345 base_view .serializer_class
4446
47+
4548class TestGetAddsPrivateHeaderForNonPublicRequests :
4649 """
4750 Tests for the newly added private Cache-Control header behaviour in the `get()` method.
4851 """
4952
50- @mock .patch ("public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate" )
53+ @mock .patch (
54+ "public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate"
55+ )
5156 @mock .patch ("public_api.version_02.views.base.Response" )
5257 @mock .patch ("public_api.version_02.views.base.APITimeSeriesRequestSerializerv2" )
5358 def test_private_header_added_when_valid_jwt (
5459 self ,
5560 mock_request_serializer_class : mock .MagicMock ,
5661 mock_response_class : mock .MagicMock ,
57- mock_backend_auth_authenticate : mock .MagicMock
58- ):
62+ mock_backend_auth_authenticate : mock .MagicMock ,
63+ ):
5964 """
6065 Given `backend.JSONWebTokenAuthentication.authenticate()` returns True
6166 When `get()` is called
@@ -90,7 +95,9 @@ def test_private_header_added_when_valid_jwt(
9095 )
9196 assert response == mocked_response
9297
93- @mock .patch ("public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate" )
98+ @mock .patch (
99+ "public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate"
100+ )
94101 @mock .patch ("public_api.version_02.views.base.Response" )
95102 @mock .patch ("public_api.version_02.views.base.APITimeSeriesRequestSerializerv2" )
96103 def test_private_header_not_added_when_is_valid_non_public_request_is_false (
@@ -132,4 +139,4 @@ def test_private_header_not_added_when_is_valid_non_public_request_is_false(
132139 # Then
133140 mock_backend_auth_authenticate .assert_called_once_with (mocked_request )
134141 mocked_response .__setitem__ .assert_not_called ()
135- assert response == mocked_response
142+ assert response == mocked_response
0 commit comments