'Test that a request for an invalid course key returns an error.'

def test_wrong_course_key(self):

    def mock_from_string(*args, **kwargs):
        'Mocked    function    to    always    raise    an    exception'
        raise InvalidKeyError('foo', 'bar')
    with patch('opaque_keys.edx.keys.CourseKey.from_string', side_effect=mock_from_string):
        resp = self.client.get(self.get_url(self.student.username))
    self.assertEqual(resp.status_code, status.HTTP_404_NOT_FOUND)
    self.assertIn('error_code', resp.data)
    self.assertEqual(resp.data['error_code'], 'invalid_course_key')
