66import pytest
77
88from 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
1518class 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: \n Line 1 \n Line 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