diff --git a/lms/djangoapps/program_enrollments/management/commands/migrate_saml_uids.py b/lms/djangoapps/program_enrollments/management/commands/migrate_saml_uids.py index 5f21c062af..7208eaa308 100644 --- a/lms/djangoapps/program_enrollments/management/commands/migrate_saml_uids.py +++ b/lms/djangoapps/program_enrollments/management/commands/migrate_saml_uids.py @@ -48,7 +48,7 @@ class Command(BaseCommand): uid_mappings = json.load(f) slug = options['saml_provider_slug'] - email_map = { m['email']: {'uid': m['student_key'], 'updated': False, 'counted': False } for m in uid_mappings } + email_map = {m['email']: {'uid': m['student_key'], 'updated': False, 'counted': False} for m in uid_mappings} user_queryset = User.objects.prefetch_related('social_auth').filter(social_auth__uid__startswith=slug + ':') users = [u for u in user_queryset] @@ -85,14 +85,16 @@ class Command(BaseCommand): 'Number of users with {slug} UserSocialAuth records for which there was no mapping in the provided file: {missed}'.format( slug=slug, missed=missed - )) + ) + ) log.info( 'Number of users identified in the mapping file without {slug} UserSocialAuth records: {not_previously_linked}'.format( slug=slug, not_previously_linked=not_previously_linked - )) - log.info('Number of mappings in the mapping file where the identified user has already been processed: {duplicated_in_mapping}'.format( - duplicated_in_mapping=duplicated_in_mapping - )) - - + ) + ) + log.info( + 'Number of mappings in the mapping file where the identified user has already been processed: {duplicated_in_mapping}'.format( + duplicated_in_mapping=duplicated_in_mapping + ) + ) diff --git a/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py b/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py index b139daf7e4..869693a843 100644 --- a/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py +++ b/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py @@ -16,6 +16,7 @@ from student.tests.factories import UserFactory _COMMAND_PATH = 'lms.djangoapps.program_enrollments.management.commands.migrate_saml_uids' + class UserSocialAuthFactory(DjangoModelFactory): """ Factory for UserSocialAuth records. @@ -41,8 +42,7 @@ class TestMigrateSamlUids(TestCase): cls.command = migrate_saml_uids.Command() def _format_email_uid_pair(self, email, uid): - return '{{"email":"{email}","student_key":"{new_urn}"}}'.format(email=email, new_urn=uid) - + return '{{"email":"{email}","student_key":"{new_urn}"}}'.format(email=email, new_urn=uid) def _format_single_email_uid_pair_json(self, email, uid): return '[{obj}]'.format(