Commit f560bd62 by Chris Dodge

put the full name into the credit service so that we don't need that profile service

parent 3d8783df
......@@ -248,10 +248,10 @@ def create_exam_attempt(exam_id, user_id, taking_as_proctored=False):
# get the name of the user, if the service is available
full_name = None
profile_service = get_runtime_service('profile')
if profile_service:
profile = profile_service(user_id)
full_name = profile['name']
credit_service = get_runtime_service('credit')
if credit_service:
credit_state = credit_service.get_credit_state(user_id, exam['course_id'])
full_name = credit_state['profile_fullname']
# now call into the backend provider to register exam attempt
external_id = get_backend_provider().register_exam_attempt(
......
......@@ -57,6 +57,30 @@ def mock_response_error(url, request): # pylint: disable=unused-argument
}
class MockCreditService(object):
"""
Simple mock of the Credit Service
"""
def get_credit_state(self, user_id, course_key): # pylint: disable=unused-argument
"""
Mock implementation
"""
return {
'enrollment_mode': 'verified',
'profile_fullname': 'Wolfgang von Strucker',
'credit_requirement_status': []
}
def set_credit_requirement_status(self, user_id, course_key, req_namespace,
req_name, status="satisfied", reason=None): # pylint: disable=unused-argument
"""
Mock implementation
"""
pass
@patch(
'django.conf.settings.PROCTORING_BACKEND_PROVIDER',
{
......@@ -84,19 +108,13 @@ class SoftwareSecureTests(TestCase):
self.user = User(username='foo', email='foo@bar.com')
self.user.save()
def mock_profile_service(user_id): # pylint: disable=unused-argument
"""
Mocked out Profile callback endpoint
"""
return {'name': 'Wolfgang von Strucker'}
set_runtime_service('profile', mock_profile_service)
set_runtime_service('credit', MockCreditService())
def tearDown(self):
"""
When tests are done
"""
set_runtime_service('profile', None)
set_runtime_service('credit', None)
def test_provider_instance(self):
"""
......
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