Last active
October 21, 2017 11:36
-
-
Save guilatrova/5bd20c98104f7515cdd37b8e4fe3ea4b to your computer and use it in GitHub Desktop.
Latrova Commits DRF Tests 1.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_list_url_only_allows_get_and_post(self): | |
resolver = self.resolve_by_name('transactions') | |
self.assert_has_actions(['get', 'post'], resolver.func.actions) | |
def test_single_url_allows_all_methods_except_post(self): | |
"""All methods are: GET, PUT, PATCH and DELETE""" | |
resolver = self.resolve_by_name('transaction', pk=1) | |
self.assert_has_actions(['get', 'put', 'patch', 'delete'], resolver.func.actions) | |
def assert_has_actions(self, allowed, actions): | |
self.assertEqual(len(allowed), len(actions)) | |
for allows in allowed: | |
self.assertIn(allows, actions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment