Skip to content
Snippets Groups Projects
Commit a28f54bf authored by Albert (AJ) St. Aubin's avatar Albert (AJ) St. Aubin
Browse files

feat: Added lms_user_id and email to data sent to Credentials for Program certs

[MICROBA-1466]
parent 2fe08ce5
Branches
Tags
No related merge requests found
......@@ -91,15 +91,15 @@ def get_certified_programs(student):
return certified_programs
def award_program_certificate(client, username, program_uuid, visible_date):
def award_program_certificate(client, user, program_uuid, visible_date):
"""
Issue a new certificate of completion to the given student for the given program.
Args:
client:
credentials API client (EdxRestApiClient)
username:
The username of the student
user:
The student's user data
program_uuid:
uuid of the completed program
visible_date:
......@@ -110,7 +110,9 @@ def award_program_certificate(client, username, program_uuid, visible_date):
"""
client.credentials.post({
'username': username,
'username': user.username,
'lms_user_id': user.id,
'email': user.email,
'credential': {
'type': PROGRAM_CERTIFICATE,
'program_uuid': program_uuid
......@@ -231,7 +233,7 @@ def award_program_certificates(self, username): # lint-amnesty, pylint: disable
visible_date = completed_programs[program_uuid]
try:
LOGGER.info(f"Visible date for user {username} : program {program_uuid} is {visible_date}")
award_program_certificate(credentials_client, username, program_uuid, visible_date)
award_program_certificate(credentials_client, student, program_uuid, visible_date)
LOGGER.info(f"Awarded certificate for program {program_uuid} to user {username}")
except exceptions.HttpNotFoundError:
LOGGER.exception(
......
......@@ -87,7 +87,8 @@ class AwardProgramCertificateTestCase(TestCase):
"""
Ensure the correct API call gets made
"""
test_username = 'test-username'
student = UserFactory(username='test-username', email='test-email@email.com')
test_client = EdxRestApiClient('http://test-server', jwt='test-token')
httpretty.register_uri(
......@@ -95,10 +96,12 @@ class AwardProgramCertificateTestCase(TestCase):
'http://test-server/credentials/',
)
tasks.award_program_certificate(test_client, test_username, 123, datetime(2010, 5, 30))
tasks.award_program_certificate(test_client, student, 123, datetime(2010, 5, 30))
expected_body = {
'username': test_username,
'username': student.username,
'lms_user_id': student.id,
'email': student.email,
'credential': {
'program_uuid': 123,
'type': tasks.PROGRAM_CERTIFICATE,
......
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