Skip to content

Commit 5174f68

Browse files
author
Marcos Dione
committed
Make sure methods returned by allowed_methods can be in any order and count. We might need to make sure that the returned value is a set.
1 parent 320fda3 commit 5174f68

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎tests/tests.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ def test_index_view_with_endpoints(self):
3131

3232
# Test the login view
3333
self.assertEqual(response.context["endpoints"][0].name_parent, "accounts")
34-
self.assertEqual(sorted(response.context["endpoints"][0].allowed_methods), sorted(['OPTIONS', 'POST']))
34+
self.assertEqual(set(response.context["endpoints"][0].allowed_methods), set(['OPTIONS', 'POST']))
3535
self.assertEqual(response.context["endpoints"][0].path, "/accounts/login/")
3636
self.assertEqual(response.context["endpoints"][0].docstring, "A view that allows users to login providing their username and password.")
3737
self.assertEqual(len(response.context["endpoints"][0].fields), 2)
3838
self.assertEqual(response.context["endpoints"][0].fields[0]["type"], "CharField")
3939
self.assertTrue(response.context["endpoints"][0].fields[0]["required"])
4040

4141
self.assertEqual(response.context["endpoints"][1].name_parent, "accounts")
42-
self.assertEqual(response.context["endpoints"][1].allowed_methods, ['POST', 'OPTIONS'])
42+
self.assertEqual(set(response.context["endpoints"][1].allowed_methods), set(['POST', 'OPTIONS']))
4343
self.assertEqual(response.context["endpoints"][1].path, "/accounts/login2/")
4444
self.assertEqual(response.context["endpoints"][1].docstring, "A view that allows users to login providing their username and password. Without serializer_class")
4545
self.assertEqual(len(response.context["endpoints"][1].fields), 2)
@@ -77,7 +77,7 @@ def test_model_viewset(self):
7777
self.assertEqual(response.context['endpoints'][6].fields[2]['to_many_relation'], True)
7878
self.assertEqual(response.context["endpoints"][11].path, '/organisation-model-viewsets/')
7979
self.assertEqual(response.context["endpoints"][12].path, '/organisation-model-viewsets/<pk>/')
80-
self.assertEqual(response.context["endpoints"][11].allowed_methods, ['GET', 'POST', 'OPTIONS'])
81-
self.assertEqual(response.context["endpoints"][12].allowed_methods, ['GET', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'])
82-
self.assertEqual(response.context["endpoints"][13].allowed_methods, ['POST', 'OPTIONS'])
80+
self.assertEqual(set(response.context["endpoints"][11].allowed_methods), set(['GET', 'POST', 'OPTIONS']))
81+
self.assertEqual(set(response.context["endpoints"][12].allowed_methods), set(['GET', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']))
82+
self.assertEqual(set(response.context["endpoints"][13].allowed_methods), set(['POST', 'OPTIONS']))
8383
self.assertEqual(response.context["endpoints"][13].docstring, 'This is a test.')

0 commit comments

Comments
 (0)