示例#1
0
 def test_get_matter_by_uid_calls_get_with_uri_and_params(
         self, mock_connection, successful_response):
     mock_connection.get.return_value = successful_response
     service = LegalHoldService(mock_connection)
     service.get_matter_by_uid("LEGAL_HOLD_UID")
     uri = "{}/{}".format(LEGAL_HOLD_URI, "LEGAL_HOLD_UID")
     mock_connection.get.assert_called_once_with(uri)
示例#2
0
    def test_get_matter_by_uid_when_forbidden_raises_legal_hold_permission_denied_error(
        self, mocker, mock_connection, successful_response
    ):
        mock_connection.get.side_effect = create_mock_error(
            Py42ForbiddenError, mocker, ""
        )
        service = LegalHoldService(mock_connection)
        with pytest.raises(Py42LegalHoldNotFoundOrPermissionDeniedError) as err:
            service.get_matter_by_uid("matter")

        expected = "Matter with UID 'matter' can not be found. Your account may not have permission to view the matter."
        assert expected in str(err.value)
        assert err.value.uid == "matter"
示例#3
0
    def test_get_matter_by_uid_when_forbidden_raises_legal_hold_permission_denied_error(
            self, mocker, mock_connection, successful_response):
        def side_effect(*args, **kwargs):
            base_err = mocker.MagicMock(spec=HTTPError)
            base_err.response = mocker.MagicMock(spec=Response)
            raise Py42ForbiddenError(base_err)

        mock_connection.get.side_effect = side_effect
        service = LegalHoldService(mock_connection)
        with pytest.raises(
                Py42LegalHoldNotFoundOrPermissionDeniedError) as err:
            service.get_matter_by_uid("matter")

        expected = "Matter with ID=matter can not be found. Your account may not have permission to view the matter."
        assert str(err.value) == expected