Commit af5e8437 by Tyler Hallada

Add id_field attribute to fix tests

parent e584a3b0
...@@ -33,6 +33,7 @@ class APIListTestCase(object): ...@@ -33,6 +33,7 @@ class APIListTestCase(object):
# Override in the subclass: # Override in the subclass:
endpoint = 'list' endpoint = 'list'
id_field = 'id'
def setUp(self): def setUp(self):
"""Set up the test case.""" """Set up the test case."""
...@@ -74,9 +75,9 @@ class APIListTestCase(object): ...@@ -74,9 +75,9 @@ class APIListTestCase(object):
['edx/demo/course'], ['edx/demo/course'],
['edx/demo/course', 'another/demo/course'] ['edx/demo/course', 'another/demo/course']
) )
def test_courses_ids(self, course_ids): def test_courses_ids(self, ids):
"""Endpoint can be called with course IDs.""" """Endpoint can be called with IDs."""
self.kwarg_test(course_ids=course_ids) self.kwarg_test(**{self.id_field: ids})
@ddt.data( @ddt.data(
['course_id'], ['course_id'],
...@@ -100,6 +101,6 @@ class APIListTestCase(object): ...@@ -100,6 +101,6 @@ class APIListTestCase(object):
['created', 'pacing_type']) ['created', 'pacing_type'])
) )
@ddt.unpack @ddt.unpack
def test_all_parameters(self, course_ids, fields, exclude): def test_all_parameters(self, ids, fields, exclude):
"""Endpoint can be called with all parameters.""" """Endpoint can be called with all parameters."""
self.kwarg_test(course_ids=course_ids, fields=fields, exclude=exclude) self.kwarg_test(**{self.id_field: ids, 'fields': fields, 'exclude': exclude})
...@@ -8,6 +8,7 @@ from analyticsclient.tests import ClientTestCase, APIListTestCase ...@@ -8,6 +8,7 @@ from analyticsclient.tests import ClientTestCase, APIListTestCase
class CourseSummariesTests(APIListTestCase, ClientTestCase): class CourseSummariesTests(APIListTestCase, ClientTestCase):
endpoint = 'course_summaries' endpoint = 'course_summaries'
id_field = 'course_ids'
@ddt.data( @ddt.data(
['123'], ['123'],
......
...@@ -7,3 +7,4 @@ from analyticsclient.tests import ClientTestCase, APIListTestCase ...@@ -7,3 +7,4 @@ from analyticsclient.tests import ClientTestCase, APIListTestCase
class ProgramsTests(APIListTestCase, ClientTestCase): class ProgramsTests(APIListTestCase, ClientTestCase):
endpoint = 'programs' endpoint = 'programs'
id_field = 'program_ids'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment