class GenericResourceTestCase(TestCase): def setUp(self): self.resource = GenericResource([NoteResource, DefinitionResource]) def test_bad_uri(self): bad_uri = '/bad_uri/' self.assertRaises(NotFound, self.resource.get_via_uri, bad_uri) def test_resource_not_registered(self): bad_uri = '/api/v1/quotes/1/' self.assertRaises(NotFound, self.resource.get_via_uri, bad_uri) def test_resource_passes_request(self): note = Note.objects.create( title='All aboard the rest train', content='Sometimes it is just better to lorem ipsum') uri = '/api/v1/notes/1/' request = MockRequest() request.GET = {'format': 'json'} request.method = 'GET' result = self.resource.get_via_uri(uri, request=request) self.assertEqual(result, note)
class GenericResourceTestCase(TestCase): def setUp(self): self.resource = GenericResource([NoteResource, DefinitionResource]) def test_bad_uri(self): bad_uri = '/bad_uri/' self.assertRaises(NotFound, self.resource.get_via_uri, bad_uri) def test_resource_not_registered(self): bad_uri = '/api/v1/quotes/1/' self.assertRaises(NotFound, self.resource.get_via_uri, bad_uri) def test_resource_passes_request(self): note = Note.objects.create( title='All aboard the rest train', content='Sometimes it is just better to lorem ipsum' ) uri = '/api/v1/notes/1/' request = MockRequest() request.GET = {'format': 'json'} request.method = 'GET' result = self.resource.get_via_uri(uri, request=request) self.assertEqual(result, note)
def setUp(self): self.resource = GenericResource([NoteResource, DefinitionResource])