def test_with_bad_user_entry(self):
     my_auth_user = """
          1	test
          two	test2
     """
     my_auth_user_profile = """
          1	Test User
          2	Second User
     """
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements(
         auth_user=my_auth_user, auth_user_profile=my_auth_user_profile)
     self.assertDictEqual(user_info.user_by_id, {
         1: {
             'user_id': 1,
             'username': '******',
             'name': 'Test User'
         },
     })
     self.assertDictEqual(user_info.user_by_username, {
         'test': {
             'user_id': 1,
             'username': '******',
             'name': 'Test User'
         },
     })
 def test_with_older_auth_user(self):
     my_auth_user = '******'
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements(
         auth_user=my_auth_user,
     )
     self.assertDictEqual(user_info.user_by_id, {
         1: {'user_id': 1, 'username': '******', 'name': 'Honor Student'},
     })
     self.assertDictEqual(user_info.user_by_username, {
         'test': {'user_id': 1, 'username': '******', 'name': 'Honor Student'},
     })
 def test_with_metadata(self):
     metadata = '{"start_time": "2015-01-01T10:30:35.123456", "end_time": "2016-01-01T-09:15:13.654321"}'
     my_auth_user = '******'.format(metadata)
     my_auth_user_profile = '{}1\tTest User'.format(metadata)
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements(
         auth_user=my_auth_user, auth_user_profile=my_auth_user_profile
     )
     self.assertDictEqual(user_info.user_by_id, {
         1: {'user_id': 1, 'username': '******', 'name': 'Test User'},
     })
     self.assertDictEqual(user_info.user_by_username, {
         'test': {'user_id': 1, 'username': '******', 'name': 'Test User'},
     })
 def test_default(self):
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements()
     self.assertDictEqual(
         user_info.user_by_id, {
             1: {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Honor Student'
             },
             2: {
                 'user_id': 2,
                 'username': '******',
                 'name': 'Audit John'
             },
             3: {
                 'user_id': 3,
                 'username': '******',
                 'name': 'Verified Vera'
             },
             4: {
                 'user_id': 4,
                 'username': '******',
                 'name': 'Static Staff'
             },
         })
     self.assertDictEqual(
         user_info.user_by_username, {
             'honor': {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Honor Student'
             },
             'audit': {
                 'user_id': 2,
                 'username': '******',
                 'name': 'Audit John'
             },
             'verified': {
                 'user_id': 3,
                 'username': '******',
                 'name': 'Verified Vera'
             },
             'staff': {
                 'user_id': 4,
                 'username': '******',
                 'name': 'Static Staff'
             },
         })
 def test_with_older_auth_user_profile(self):
     my_auth_user_profile = '1\tTest User'
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements(
         auth_user_profile=my_auth_user_profile, )
     self.assertDictEqual(
         user_info.user_by_id, {
             1: {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Test User'
             },
             2: {
                 'user_id': 2,
                 'username': '******'
             },
             3: {
                 'user_id': 3,
                 'username': '******'
             },
             4: {
                 'user_id': 4,
                 'username': '******'
             },
         })
     self.assertDictEqual(
         user_info.user_by_username, {
             'honor': {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Test User'
             },
             'audit': {
                 'user_id': 2,
                 'username': '******'
             },
             'verified': {
                 'user_id': 3,
                 'username': '******'
             },
             'staff': {
                 'user_id': 4,
                 'username': '******'
             },
         })
 def test_with_empty_username(self):
     my_auth_user = """
          1	test
          2	{intentional_blank}
          3	test3
     """.format(intentional_blank='   ')
     my_auth_user_profile = """
          1	Test User
          2	Second User
          3	Third User
     """
     user_info = obfuscate_util.UserInfoMixin()
     user_info.user_info_requirements = get_mock_user_info_requirements(
         auth_user=my_auth_user, auth_user_profile=my_auth_user_profile)
     self.assertDictEqual(
         user_info.user_by_id, {
             1: {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Test User'
             },
             3: {
                 'user_id': 3,
                 'username': '******',
                 'name': 'Third User'
             },
         })
     self.assertDictEqual(
         user_info.user_by_username, {
             'test': {
                 'user_id': 1,
                 'username': '******',
                 'name': 'Test User'
             },
             'test3': {
                 'user_id': 3,
                 'username': '******',
                 'name': 'Third User'
             },
         })