コード例 #1
0
    def test_map_users_response_empty(self):
        """If no STAFF_ID, then continue, and ignore record"""
        profile = ProfileFactory()
        profile.section_code = "SEC"
        profile.save()
        data = {
            "ORG_UNIT_NAME": "UNICEF",
            "STAFF_ID": None,
            "MANAGER_ID": "",
            "ORG_UNIT_CODE": "101",
            "VENDOR_CODE": "202",
            "STAFF_EMAIL": "*****@*****.**",
        }

        self.assertEqual(self.mapper.section_users, {})
        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, {})
コード例 #2
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})
コード例 #3
0
ファイル: test_tasks.py プロジェクト: alhadheri/etools
 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)
コード例 #4
0
ファイル: test_models.py プロジェクト: azizur77/etools
 def test_save_vendor_number(self):
     profile = ProfileFactory()
     profile.vendor_number = ""
     profile.save()
     self.assertIsNone(profile.vendor_number)
コード例 #5
0
ファイル: test_models.py プロジェクト: azizur77/etools
 def test_save_staff_id(self):
     profile = ProfileFactory()
     profile.staff_id = ""
     profile.save()
     self.assertIsNone(profile.staff_id)