Skip to content

Commit d24cbf1

Browse files
fixed tests
1 parent 9b90568 commit d24cbf1

5 files changed

Lines changed: 176 additions & 124 deletions

File tree

tests/outputmanagement/unit/test_basic.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,28 @@ def test_client_provider_import(self):
2727
def test_constants_import(self):
2828
"""Test that constants can be imported."""
2929
from sap_cloud_sdk.outputmanagement.constants import (
30-
DEFAULT_DESTINATION_NAME,
31-
OUTPUT_MANAGEMENT_SERVICE_PATH,
32-
EMAIL_SERVICE_PATH,
30+
Constants,
31+
FileFormat,
32+
Channel,
33+
Status,
3334
)
34-
assert DEFAULT_DESTINATION_NAME is not None
35-
assert OUTPUT_MANAGEMENT_SERVICE_PATH is not None
36-
assert EMAIL_SERVICE_PATH is not None
35+
assert Constants.API_OUTPUT_CONTROL is not None
36+
assert FileFormat.PDF is not None
37+
assert Channel.EMAIL is not None
38+
assert Status.PENDING is not None
3739

3840
def test_exceptions_import(self):
3941
"""Test that exceptions can be imported."""
4042
from sap_cloud_sdk.outputmanagement.exceptions import (
41-
OutputManagementError,
42-
OutputManagementValidationError,
43-
OutputManagementClientError,
43+
OutputManagementException,
44+
ValidationException,
45+
AuthenticationException,
46+
NetworkException,
4447
)
45-
assert OutputManagementError is not None
46-
assert OutputManagementValidationError is not None
47-
assert OutputManagementClientError is not None
48+
assert OutputManagementException is not None
49+
assert ValidationException is not None
50+
assert AuthenticationException is not None
51+
assert NetworkException is not None
4852

4953
def test_models_import(self):
5054
"""Test that models can be imported."""

tests/outputmanagement/unit/test_comprehensive.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
PreGeneratedAttachment,
1414
)
1515
from sap_cloud_sdk.outputmanagement.exceptions import (
16-
OutputManagementError,
17-
OutputManagementValidationError,
18-
OutputManagementClientError,
16+
OutputManagementException,
17+
ValidationException,
18+
AuthenticationException,
1919
)
2020

2121

@@ -176,27 +176,27 @@ def test_exception_with_nested_message(self):
176176
try:
177177
raise ValueError("Inner error")
178178
except ValueError as e:
179-
error = OutputManagementError(f"Outer error: {str(e)}")
180-
assert "Inner error" in str(error)
181-
assert "Outer error" in str(error)
179+
error = OutputManagementException(f"Outer error: {str(e)}")
180+
assert "Inner error" in error.message
181+
assert "Outer error" in error.message
182182

183183
def test_multiple_exception_types(self):
184184
"""Test catching different exception types."""
185185
errors = [
186-
OutputManagementError("General error"),
187-
OutputManagementValidationError("Validation error"),
188-
OutputManagementClientError("Client error"),
186+
OutputManagementException("General error"),
187+
ValidationException("Validation error"),
188+
AuthenticationException("Authentication error"),
189189
]
190190

191191
for error in errors:
192-
assert isinstance(error, OutputManagementError)
192+
assert isinstance(error, OutputManagementException)
193193
assert isinstance(error, Exception)
194194

195195
def test_exception_repr(self):
196196
"""Test exception representation."""
197-
error = OutputManagementError("Test error")
197+
error = OutputManagementException("Test error")
198198
repr_str = repr(error)
199-
assert "OutputManagementError" in repr_str or "Test error" in repr_str
199+
assert "OutputManagementException" in repr_str or "Test error" in repr_str
200200

201201

202202
class TestModelComparisons:

tests/outputmanagement/unit/test_constants.py

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,63 @@
66
import pytest
77

88
from sap_cloud_sdk.outputmanagement.constants import (
9-
DEFAULT_DESTINATION_NAME,
10-
OUTPUT_MANAGEMENT_SERVICE_PATH,
11-
EMAIL_SERVICE_PATH,
9+
Constants,
10+
FileFormat,
11+
Channel,
12+
Status,
1213
)
1314

1415

1516
class TestConstants:
1617
"""Test output management constants."""
1718

18-
def test_default_destination_name_exists(self):
19-
"""Test default destination name constant exists."""
20-
assert DEFAULT_DESTINATION_NAME is not None
21-
assert isinstance(DEFAULT_DESTINATION_NAME, str)
22-
assert len(DEFAULT_DESTINATION_NAME) > 0
23-
24-
def test_output_management_service_path_exists(self):
25-
"""Test output management service path constant exists."""
26-
assert OUTPUT_MANAGEMENT_SERVICE_PATH is not None
27-
assert isinstance(OUTPUT_MANAGEMENT_SERVICE_PATH, str)
28-
assert len(OUTPUT_MANAGEMENT_SERVICE_PATH) > 0
29-
30-
def test_email_service_path_exists(self):
31-
"""Test email service path constant exists."""
32-
assert EMAIL_SERVICE_PATH is not None
33-
assert isinstance(EMAIL_SERVICE_PATH, str)
34-
assert len(EMAIL_SERVICE_PATH) > 0
35-
36-
def test_service_paths_start_with_slash(self):
37-
"""Test that service paths start with a slash."""
38-
assert OUTPUT_MANAGEMENT_SERVICE_PATH.startswith("/")
39-
assert EMAIL_SERVICE_PATH.startswith("/")
40-
41-
def test_constants_are_strings(self):
42-
"""Test that all constants are strings."""
43-
assert isinstance(DEFAULT_DESTINATION_NAME, str)
44-
assert isinstance(OUTPUT_MANAGEMENT_SERVICE_PATH, str)
45-
assert isinstance(EMAIL_SERVICE_PATH, str)
46-
47-
def test_constants_not_empty(self):
48-
"""Test that constants are not empty strings."""
49-
assert DEFAULT_DESTINATION_NAME != ""
50-
assert OUTPUT_MANAGEMENT_SERVICE_PATH != ""
51-
assert EMAIL_SERVICE_PATH != ""
52-
53-
def test_service_paths_format(self):
54-
"""Test service paths follow expected format."""
55-
# Service paths should be valid URL paths
56-
assert not OUTPUT_MANAGEMENT_SERVICE_PATH.endswith("/")
57-
assert not EMAIL_SERVICE_PATH.endswith("/")
58-
assert " " not in OUTPUT_MANAGEMENT_SERVICE_PATH
59-
assert " " not in EMAIL_SERVICE_PATH
19+
def test_api_output_control_exists(self):
20+
"""Test API output control constant exists."""
21+
assert Constants.API_OUTPUT_CONTROL is not None
22+
assert isinstance(Constants.API_OUTPUT_CONTROL, str)
23+
assert len(Constants.API_OUTPUT_CONTROL) > 0
24+
25+
def test_api_output_control_starts_with_slash(self):
26+
"""Test that API path starts with a slash."""
27+
assert Constants.API_OUTPUT_CONTROL.startswith("/")
28+
29+
def test_header_constants_exist(self):
30+
"""Test that header constants exist."""
31+
assert Constants.CONTENT_TYPE is not None
32+
assert Constants.APPLICATION_JSON is not None
33+
assert Constants.AUTHORIZATION is not None
34+
assert Constants.BEARER is not None
35+
36+
def test_header_constants_are_strings(self):
37+
"""Test that header constants are strings."""
38+
assert isinstance(Constants.CONTENT_TYPE, str)
39+
assert isinstance(Constants.APPLICATION_JSON, str)
40+
assert isinstance(Constants.AUTHORIZATION, str)
41+
assert isinstance(Constants.BEARER, str)
42+
43+
def test_content_type_constants(self):
44+
"""Test content type constants."""
45+
assert Constants.CONTENT_TYPE_JSON == "application/json"
46+
assert Constants.CONTENT_TYPE_PDF == "application/pdf"
47+
48+
def test_file_format_enum(self):
49+
"""Test FileFormat enum."""
50+
assert FileFormat.PDF.value == "PDF"
51+
assert FileFormat.DOCX.value == "DOCX"
52+
assert FileFormat.HTML.value == "HTML"
53+
assert FileFormat.XML.value == "XML"
54+
55+
def test_channel_enum(self):
56+
"""Test Channel enum."""
57+
assert Channel.EMAIL.value == "EMAIL"
58+
assert Channel.INTERNAL_EMAIL.value == "INTERNAL_EMAIL"
59+
assert Channel.DIRECT_SHARE.value == "DIRECT_SHARE"
60+
assert Channel.FORM.value == "FORM"
61+
62+
def test_status_enum(self):
63+
"""Test Status enum."""
64+
assert Status.PENDING.value == "PENDING"
65+
assert Status.IN_PROGRESS.value == "IN_PROGRESS"
66+
assert Status.COMPLETED.value == "COMPLETED"
67+
assert Status.FAILED.value == "FAILED"
68+
assert Status.CANCELLED.value == "CANCELLED"

tests/outputmanagement/unit/test_exceptions.py

Lines changed: 86 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,115 @@
66
import pytest
77

88
from sap_cloud_sdk.outputmanagement.exceptions import (
9-
OutputManagementError,
10-
OutputManagementValidationError,
11-
OutputManagementClientError,
9+
OutputManagementException,
10+
ValidationException,
11+
AuthenticationException,
12+
NetworkException,
13+
DestinationNotFoundException,
14+
DestinationAccessException,
1215
)
1316

1417

1518
class TestOutputManagementExceptions:
1619
"""Test output management exception classes."""
1720

18-
def test_output_management_error_basic(self):
19-
"""Test basic OutputManagementError."""
20-
error = OutputManagementError("Test error")
21-
assert str(error) == "Test error"
21+
def test_output_management_exception_basic(self):
22+
"""Test basic OutputManagementException."""
23+
error = OutputManagementException("Test error")
24+
assert error.message == "Test error"
2225
assert isinstance(error, Exception)
2326

24-
def test_output_management_error_with_message(self):
25-
"""Test OutputManagementError with custom message."""
27+
def test_output_management_exception_with_message(self):
28+
"""Test OutputManagementException with custom message."""
2629
message = "Something went wrong in output management"
27-
error = OutputManagementError(message)
28-
assert str(error) == message
29-
30-
def test_output_management_validation_error(self):
31-
"""Test OutputManagementValidationError."""
32-
error = OutputManagementValidationError("Validation failed")
33-
assert str(error) == "Validation failed"
34-
assert isinstance(error, OutputManagementError)
30+
error = OutputManagementException(message)
31+
assert error.message == message
32+
33+
def test_output_management_exception_with_error_code(self):
34+
"""Test OutputManagementException with error code."""
35+
error = OutputManagementException("Test error", error_code="ERR001")
36+
assert error.message == "Test error"
37+
assert error.error_code == "ERR001"
38+
assert "ERR001" in str(error)
39+
40+
def test_output_management_exception_with_status_code(self):
41+
"""Test OutputManagementException with status code."""
42+
error = OutputManagementException("Test error", status_code=400)
43+
assert error.message == "Test error"
44+
assert error.status_code == 400
45+
assert "400" in str(error)
46+
47+
def test_validation_exception(self):
48+
"""Test ValidationException."""
49+
error = ValidationException("Validation failed")
50+
assert error.message == "Validation failed"
51+
assert isinstance(error, OutputManagementException)
52+
assert isinstance(error, Exception)
53+
54+
def test_authentication_exception(self):
55+
"""Test AuthenticationException."""
56+
error = AuthenticationException("Authentication failed")
57+
assert error.message == "Authentication failed"
58+
assert isinstance(error, OutputManagementException)
3559
assert isinstance(error, Exception)
3660

37-
def test_output_management_client_error(self):
38-
"""Test OutputManagementClientError."""
39-
error = OutputManagementClientError("Client error occurred")
40-
assert str(error) == "Client error occurred"
41-
assert isinstance(error, OutputManagementError)
61+
def test_network_exception(self):
62+
"""Test NetworkException."""
63+
error = NetworkException("Network error occurred")
64+
assert error.message == "Network error occurred"
65+
assert isinstance(error, OutputManagementException)
4266
assert isinstance(error, Exception)
4367

68+
def test_destination_not_found_exception(self):
69+
"""Test DestinationNotFoundException."""
70+
error = DestinationNotFoundException("Destination not found")
71+
assert error.message == "Destination not found"
72+
assert isinstance(error, OutputManagementException)
73+
74+
def test_destination_access_exception(self):
75+
"""Test DestinationAccessException."""
76+
error = DestinationAccessException("Cannot access destination")
77+
assert error.message == "Cannot access destination"
78+
assert isinstance(error, OutputManagementException)
79+
4480
def test_exception_inheritance_chain(self):
4581
"""Test exception inheritance chain."""
46-
assert issubclass(OutputManagementValidationError, OutputManagementError)
47-
assert issubclass(OutputManagementClientError, OutputManagementError)
48-
assert issubclass(OutputManagementError, Exception)
82+
assert issubclass(ValidationException, OutputManagementException)
83+
assert issubclass(AuthenticationException, OutputManagementException)
84+
assert issubclass(NetworkException, OutputManagementException)
85+
assert issubclass(DestinationNotFoundException, OutputManagementException)
86+
assert issubclass(DestinationAccessException, OutputManagementException)
87+
assert issubclass(OutputManagementException, Exception)
4988

5089
def test_exceptions_can_be_raised(self):
5190
"""Test that exceptions can be raised and caught."""
52-
with pytest.raises(OutputManagementError):
53-
raise OutputManagementError("Test")
91+
with pytest.raises(OutputManagementException):
92+
raise OutputManagementException("Test")
5493

55-
with pytest.raises(OutputManagementValidationError):
56-
raise OutputManagementValidationError("Test")
94+
with pytest.raises(ValidationException):
95+
raise ValidationException("Test")
5796

58-
with pytest.raises(OutputManagementClientError):
59-
raise OutputManagementClientError("Test")
97+
with pytest.raises(AuthenticationException):
98+
raise AuthenticationException("Test")
6099

61100
def test_validation_error_caught_as_base_error(self):
62-
"""Test that ValidationError can be caught as base OutputManagementError."""
63-
with pytest.raises(OutputManagementError):
64-
raise OutputManagementValidationError("Validation failed")
101+
"""Test that ValidationException can be caught as base OutputManagementException."""
102+
with pytest.raises(OutputManagementException):
103+
raise ValidationException("Validation failed")
65104

66-
def test_client_error_caught_as_base_error(self):
67-
"""Test that ClientError can be caught as base OutputManagementError."""
68-
with pytest.raises(OutputManagementError):
69-
raise OutputManagementClientError("Client failed")
105+
def test_authentication_error_caught_as_base_error(self):
106+
"""Test that AuthenticationException can be caught as base OutputManagementException."""
107+
with pytest.raises(OutputManagementException):
108+
raise AuthenticationException("Auth failed")
70109

71110
def test_exception_with_empty_message(self):
72111
"""Test exceptions with empty message."""
73-
error = OutputManagementError("")
74-
assert str(error) == ""
75-
76-
def test_exception_with_multiline_message(self):
77-
"""Test exceptions with multiline message."""
78-
message = "Error occurred:\nLine 1\nLine 2"
79-
error = OutputManagementError(message)
80-
assert str(error) == message
81-
assert "\n" in str(error)
112+
error = OutputManagementException("")
113+
assert error.message == ""
114+
115+
def test_exception_with_details(self):
116+
"""Test exceptions with additional details."""
117+
details = {"field": "email", "reason": "invalid format"}
118+
error = OutputManagementException("Validation error", details=details)
119+
assert error.details == details
120+
assert error.details["field"] == "email"

0 commit comments

Comments
 (0)