Skip to content

Commit

Permalink
Merge pull request #114 from aismail/b/#113-rename-all-resources
Browse files Browse the repository at this point in the history
B/#113 rename all resources
  • Loading branch information
Andrei-Adnan Ismail committed May 10, 2013
2 parents be782f3 + 4a7c3b2 commit 258cfa5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions vmc_backend/api/resources.py
Expand Up @@ -19,6 +19,7 @@ class Meta(BaseResource.Meta):
allowed_methods = ['get', 'post']
authentication = Authentication()
authorization = Authorization()
resource_name = 'submissions'


class AssignmentResource(BaseResource):
Expand All @@ -31,6 +32,7 @@ class Meta(BaseResource.Meta):
}
queryset = Assignment.objects.all()
allowed_methods = ['get', 'post']
resource_name = 'assignments'


class SubjectResource(BaseResource):
Expand Down
2 changes: 1 addition & 1 deletion vmc_backend/api/tests/assignment_resource_test.py
Expand Up @@ -9,7 +9,7 @@ def setUp(self):
super(AssignmentResourceTest, self).setUp()
self.as1 = AssignmentFactory()
self.as2 = AssignmentFactory()
self.base_url = '/api/v1/assignment/'
self.base_url = '/api/v1/assignments/'

def test_get_detail_json(self):
resp = self.api_client.get(self.base_url, format='json')
Expand Down
4 changes: 2 additions & 2 deletions vmc_backend/api/tests/subject_resource_test.py
Expand Up @@ -9,14 +9,14 @@ def setUp(self):
self.subject_1 = SubjectFactory()
self.subject_2 = SubjectFactory()

self.detail_url = '/api/v1/subject/{0}/'.format(self.subject_1.pk)
self.detail_url = '/api/v1/subjects/{0}/'.format(self.subject_1.pk)

def test_get_detail_json(self):
resp = self.api_client.get(self.detail_url, format='json')
self.assertValidJSONResponse(resp)

def test_get_list_json(self):
resp = self.api_client.get('/api/v1/subject/', format='json')
resp = self.api_client.get('/api/v1/subjects/', format='json')
self.assertValidJSONResponse(resp)

self.assertEqual(len(self.deserialize(resp)['objects']), 2)
8 changes: 4 additions & 4 deletions vmc_backend/api/tests/submission_resource_tests.py
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
self.user = User.objects.create_user(self.username,
'daniel@example.com', self.password)

self.detail_url = '/api/v1/submission/%d/' % self.subm1.pk
self.detail_url = '/api/v1/submissions/%d/' % self.subm1.pk

self.post_data = {
'student_id': self.subm1.student_id,
Expand All @@ -36,7 +36,7 @@ def test_get_detail_json(self):
self.assertValidJSONResponse(resp)

def test_get_list_json(self):
resp = self.api_client.get('/api/v1/submission/', format='json',
resp = self.api_client.get('/api/v1/submissions/', format='json',
authentication=self.get_credentials())
self.assertValidJSONResponse(resp)
self.assertEqual(len(self.deserialize(resp)['objects']), 2)
Expand All @@ -45,15 +45,15 @@ def test_post_list(self):
# Check how many are there first.
self.assertEqual(Submission.objects.count(), 2)
# from nose.tools import set_trace; set_trace()
self.assertHttpCreated(self.api_client.post('/api/v1/submission/',
self.assertHttpCreated(self.api_client.post('/api/v1/submissions/',
format='json', data=self.post_data))
# Verify a new one has been added.
self.assertEqual(Submission.objects.count(), 3)

def test_filtering_by_assignment(self):
""" Asserts if filtering by assignment returns right objects
"""
resp = self.api_client.get('/api/v1/submission/?assignment_id={0}'.
resp = self.api_client.get('/api/v1/submissions/?assignment_id={0}'.
format(self.subm1.assignment_id), format='json')
self.assertEqual(len(self.deserialize(resp)['objects']), 1)

Expand Down

0 comments on commit 258cfa5

Please sign in to comment.