Last active
November 20, 2015 01:42
-
-
Save ydaniv/cf17ef92ed8cc9435498 to your computer and use it in GitHub Desktop.
2 API alternatives for the Django-REST-assured testing library.
This file contains 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
############ | |
# Option A # | |
############ | |
class CategoryTestCase(RESTAPITestCase): | |
"""Tests Category API endpoints.""" | |
base_name = 'category' | |
user_factory = account_factories.Admin | |
factory_class = factories.Category | |
def test_list(self): | |
return self.listview() | |
def test_retrieve(self): | |
return self.detailview() | |
def test_create(self): | |
return self.createview({'name': 'Soccer'}) | |
def test_destroy(self): | |
return self.destroyview() | |
def test_update(self): | |
return self.updateview({'name': 'Football'}) | |
############ | |
# Option B # | |
############ | |
class CategoryTestCase(ReadWriteRESTTestCase, BaseRESTAPITestCase): | |
"""Tests Category API endpoints.""" | |
base_name = 'category' | |
user_factory = account_factories.Admin | |
factory_class = factories.Category | |
create_data = {'name': 'Soccer'} | |
update_data = {'name': 'Football'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment