Commit fb9e563d by Clinton Blackburn

Merge pull request #6 from edx/trailing-slash

Added trailing slashes to URLs to avoid redirect
parents 6bd371c7 8e81f7c3
......@@ -20,17 +20,18 @@ class Client(object):
way to get access to those classes and their methods.
"""
def __init__(self, base_url, auth_token=None):
def __init__(self, base_url, auth_token=None, timeout=0.25):
"""
Initialize the client.
Arguments:
base_url (str): URL of the API server (e.g. http://analytics.edx.org/api/v0)
auth_token (str): Authentication token
timeout (number): Maximum number of seconds during which all requests musts complete
"""
self.base_url = base_url.rstrip('/')
self.auth_token = auth_token
self.timeout = 0.1
self.timeout = timeout
self.status = Status(self)
self.courses = lambda course_id: Course(self, course_id)
......
......@@ -24,7 +24,7 @@ class Course(object):
Arguments:
demographic (str): Demographic by which enrollment data should be grouped.
"""
return self.client.get('courses/{0}/enrollment/{1}'.format(self.course_id, demographic))
return self.client.get('courses/{0}/enrollment/{1}/'.format(self.course_id, demographic))
def recent_activity(self, activity_type=at.ANY):
"""
......@@ -33,4 +33,4 @@ class Course(object):
Arguments:
activity_type (str): The type of recent activity to return. Defaults to ANY.
"""
return self.client.get('courses/{0}/recent_activity?activity_type={1}'.format(self.course_id, activity_type))
return self.client.get('courses/{0}/recent_activity/?activity_type={1}'.format(self.course_id, activity_type))
......@@ -19,9 +19,9 @@ class CoursesTests(ClientTestCase):
httpretty.disable()
def assertEnrollmentResponseData(self, course, data, demographic=None):
uri = self.get_api_url('courses/{0}/enrollment'.format(course.course_id))
uri = self.get_api_url('courses/{0}/enrollment/'.format(course.course_id))
if demographic:
uri += '/%s' % demographic
uri += '%s/' % demographic
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(data))
self.assertDictEqual(data, course.enrollment(demographic))
......@@ -34,7 +34,7 @@ class CoursesTests(ClientTestCase):
u'count': 200,
}
uri = self.get_api_url('courses/{0}/recent_activity?activity_type={1}'.format(self.course_id, activity_type))
uri = self.get_api_url('courses/{0}/recent_activity/?activity_type={1}'.format(self.course_id, activity_type))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertDictEqual(body, self.course.recent_activity(activity_type))
......
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