'Call a PUT on `handler` for a given `course` and return its response as a dict.
Raise an exception if response status code is not as expected.'

def put_handler(self, course, cohort=None, data=None, expected_response_code=200, handler=cohort_handler):

    if (not isinstance(data, basestring)):
        data = json.dumps((data or {}))
    request = RequestFactory().put(path='dummy    path', data=data, content_type='application/json')
    request.user = self.staff_user
    if cohort:
        response = handler(request, unicode(course.id), cohort.id)
    else:
        response = handler(request, unicode(course.id))
    self.assertEqual(response.status_code, expected_response_code)
    return json.loads(response.content)
