Exemple #1
0
    def test_create_user_when_service_returns_cannot_find_user_bad_request_raises_unable_to_create_error(
        self,
        mocker,
        mock_detection_list_user_service,
        mock_departing_employee_service,
        mock_high_risk_employee_service,
    ):
        mock_err_response_content = """
            {
                "pop-bulletin": {
                    "type$": "com.code42.casemanagement.CaseMessages.InvalidUser",
                    "text$": "Could not find user: testusername",
                    "details": [],
                    "user": "******"
                }
            }"""
        mock_detection_list_user_service.get.side_effect = create_mock_error(
            Py42BadRequestError, mocker, mock_err_response_content)

        client = DetectionListsClient(
            mock_detection_list_user_service,
            mock_departing_employee_service,
            mock_high_risk_employee_service,
        )
        with pytest.raises(Py42UnableToCreateProfileError) as err:
            client.create_user("testusername")

        assert (
            "Detection-list profiles are now created automatically on the server. "
            "Unable to find a detection-list profile for 'testusername'. It is "
            "possibly still being created if you just recently created the Code42 "
            "user." in str(err.value))
        assert err.value.username == "testusername"
Exemple #2
0
 def test_create_user_calls_user_client_with_expected_values(
     self,
     mock_detection_list_user_service,
     mock_departing_employee_service,
     mock_high_risk_employee_service,
 ):
     client = DetectionListsClient(
         mock_detection_list_user_service,
         mock_departing_employee_service,
         mock_high_risk_employee_service,
     )
     client.create_user("testusername")
     mock_detection_list_user_service.get.assert_called_once_with(
         "testusername")
Exemple #3
0
 def test_create_user_when_service_returns_bad_request_raises(
     self,
     mocker,
     mock_detection_list_user_service,
     mock_departing_employee_service,
     mock_high_risk_employee_service,
 ):
     mock_detection_list_user_service.get.side_effect = create_mock_error(
         Py42BadRequestError, mocker, "")
     client = DetectionListsClient(
         mock_detection_list_user_service,
         mock_departing_employee_service,
         mock_high_risk_employee_service,
     )
     with pytest.raises(Py42BadRequestError):
         client.create_user("testusername")