Пример #1
0
 def test_map_users(self):
     """If user is found, ensure section_users is updated"""
     profile = ProfileFactory()
     profile.section_code = "SEC"
     profile.staff_id = profile.user.pk
     profile.save()
     data = {
         "ORG_UNIT_NAME": "UNICEF",
         "STAFF_ID": profile.staff_id,
         "MANAGER_ID": "",
         "ORG_UNIT_CODE": "101",
         "VENDOR_CODE": "202",
         "STAFF_EMAIL": "*****@*****.**",
         "STAFF_POST_NO": "123",
     }
     mock_request = Mock()
     mock_request.get().json.return_value = json.dumps([data])
     mock_request.get().status_code = 200
     self.assertFalse(self.mapper.section_users, {})
     with patch("etools.applications.users.tasks.requests", mock_request):
         self.mapper.map_users()
     self.assertEqual(self.mapper.section_users,
                      {profile.user.pk: profile.user})
Пример #2
0
 def test_map(self):
     profile = ProfileFactory()
     profile.staff_id = profile.user.pk
     profile.save()
     data = {
         "ORG_UNIT_NAME": "UNICEF",
         "STAFF_ID": profile.staff_id,
         "MANAGER_ID": "",
         "ORG_UNIT_CODE": "101",
         "VENDOR_CODE": "202",
         "STAFF_EMAIL": "*****@*****.**",
         "STAFF_POST_NO": "123",
     }
     mock_request = Mock()
     mock_request.get().json.return_value = json.dumps([data])
     mock_request.get().status_code = 200
     with patch("etools.applications.users.tasks.VisionSyncLog",
                self.mock_log):
         with patch("etools.applications.users.tasks.requests",
                    mock_request):
             tasks.map_users()
     self.assertTrue(self.mock_log.call_count(), 1)
     self.assertTrue(self.mock_log.save.call_count(), 1)
Пример #3
0
 def test_save_staff_id(self):
     profile = ProfileFactory()
     profile.staff_id = ""
     profile.save()
     self.assertIsNone(profile.staff_id)