Skip to content

Instantly share code, notes, and snippets.

@ydaniv
Last active November 20, 2015 01:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ydaniv/cf17ef92ed8cc9435498 to your computer and use it in GitHub Desktop.
Save ydaniv/cf17ef92ed8cc9435498 to your computer and use it in GitHub Desktop.
2 API alternatives for the Django-REST-assured testing library.
############
# 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