1+ import pytest
2+ from pydantic import ValidationError
3+
4+ from app .models .manual_retry import ManualRetryRequestModel , ManualRetryResponseModel
5+ from app .models .state_status_enum import StateStatusEnum
6+
7+
8+ class TestManualRetryRequestModel :
9+ """Test cases for ManualRetryRequestModel"""
10+
11+ def test_manual_retry_request_model_valid_data (self ):
12+ """Test ManualRetryRequestModel with valid fanout_id"""
13+ # Arrange & Act
14+ fanout_id = "test-fanout-id-123"
15+ model = ManualRetryRequestModel (fanout_id = fanout_id )
16+
17+ # Assert
18+ assert model .fanout_id == fanout_id
19+
20+ def test_manual_retry_request_model_empty_fanout_id (self ):
21+ """Test ManualRetryRequestModel with empty fanout_id"""
22+ # Arrange & Act
23+ fanout_id = ""
24+ model = ManualRetryRequestModel (fanout_id = fanout_id )
25+
26+ # Assert
27+ assert model .fanout_id == fanout_id
28+
29+ def test_manual_retry_request_model_uuid_fanout_id (self ):
30+ """Test ManualRetryRequestModel with UUID fanout_id"""
31+ # Arrange & Act
32+ fanout_id = "550e8400-e29b-41d4-a716-446655440000"
33+ model = ManualRetryRequestModel (fanout_id = fanout_id )
34+
35+ # Assert
36+ assert model .fanout_id == fanout_id
37+
38+ def test_manual_retry_request_model_long_fanout_id (self ):
39+ """Test ManualRetryRequestModel with long fanout_id"""
40+ # Arrange & Act
41+ fanout_id = "a" * 1000 # Very long string
42+ model = ManualRetryRequestModel (fanout_id = fanout_id )
43+
44+ # Assert
45+ assert model .fanout_id == fanout_id
46+
47+ def test_manual_retry_request_model_special_characters_fanout_id (self ):
48+ """Test ManualRetryRequestModel with special characters in fanout_id"""
49+ # Arrange & Act
50+ fanout_id = "test-fanout@#$%^&*()_+-={}[]|\\ :;\" '<>?,./"
51+ model = ManualRetryRequestModel (fanout_id = fanout_id )
52+
53+ # Assert
54+ assert model .fanout_id == fanout_id
55+
56+ def test_manual_retry_request_model_missing_fanout_id (self ):
57+ """Test ManualRetryRequestModel with missing fanout_id field"""
58+ # Arrange & Act & Assert
59+ with pytest .raises (ValidationError ) as exc_info :
60+ ManualRetryRequestModel () # type: ignore
61+
62+ assert "fanout_id" in str (exc_info .value )
63+ assert "Field required" in str (exc_info .value )
64+
65+ def test_manual_retry_request_model_none_fanout_id (self ):
66+ """Test ManualRetryRequestModel with None fanout_id"""
67+ # Arrange & Act & Assert
68+ with pytest .raises (ValidationError ) as exc_info :
69+ ManualRetryRequestModel (fanout_id = None ) # type: ignore
70+
71+ assert "fanout_id" in str (exc_info .value )
72+
73+ def test_manual_retry_request_model_numeric_fanout_id (self ):
74+ """Test ManualRetryRequestModel with numeric fanout_id (should fail validation)"""
75+ # Arrange & Act & Assert
76+ with pytest .raises (ValidationError ) as exc_info :
77+ ManualRetryRequestModel (fanout_id = 12345 ) # type: ignore
78+
79+ assert "string_type" in str (exc_info .value )
80+
81+ def test_manual_retry_request_model_dict_representation (self ):
82+ """Test ManualRetryRequestModel dict representation"""
83+ # Arrange & Act
84+ fanout_id = "test-fanout-id"
85+ model = ManualRetryRequestModel (fanout_id = fanout_id )
86+
87+ # Assert
88+ expected_dict = {"fanout_id" : fanout_id }
89+ assert model .model_dump () == expected_dict
90+
91+ def test_manual_retry_request_model_json_serialization (self ):
92+ """Test ManualRetryRequestModel JSON serialization"""
93+ # Arrange & Act
94+ fanout_id = "test-fanout-id"
95+ model = ManualRetryRequestModel (fanout_id = fanout_id )
96+
97+ # Assert
98+ json_str = model .model_dump_json ()
99+ assert f'"fanout_id":"{ fanout_id } "' in json_str
100+
101+
102+ class TestManualRetryResponseModel :
103+ """Test cases for ManualRetryResponseModel"""
104+
105+ def test_manual_retry_response_model_valid_data (self ):
106+ """Test ManualRetryResponseModel with valid data"""
107+ # Arrange & Act
108+ state_id = "507f1f77bcf86cd799439011"
109+ status = StateStatusEnum .CREATED
110+ model = ManualRetryResponseModel (id = state_id , status = status )
111+
112+ # Assert
113+ assert model .id == state_id
114+ assert model .status == status
115+
116+ def test_manual_retry_response_model_all_status_types (self ):
117+ """Test ManualRetryResponseModel with all possible status values"""
118+ # Arrange & Act & Assert
119+ state_id = "507f1f77bcf86cd799439011"
120+
121+ for status in StateStatusEnum :
122+ model = ManualRetryResponseModel (id = state_id , status = status )
123+ assert model .id == state_id
124+ assert model .status == status
125+
126+ def test_manual_retry_response_model_created_status (self ):
127+ """Test ManualRetryResponseModel with CREATED status"""
128+ # Arrange & Act
129+ state_id = "507f1f77bcf86cd799439011"
130+ status = StateStatusEnum .CREATED
131+ model = ManualRetryResponseModel (id = state_id , status = status )
132+
133+ # Assert
134+ assert model .id == state_id
135+ assert model .status == StateStatusEnum .CREATED
136+
137+ def test_manual_retry_response_model_retry_created_status (self ):
138+ """Test ManualRetryResponseModel with RETRY_CREATED status"""
139+ # Arrange & Act
140+ state_id = "507f1f77bcf86cd799439011"
141+ status = StateStatusEnum .RETRY_CREATED
142+ model = ManualRetryResponseModel (id = state_id , status = status )
143+
144+ # Assert
145+ assert model .id == state_id
146+ assert model .status == StateStatusEnum .RETRY_CREATED
147+
148+ def test_manual_retry_response_model_missing_id (self ):
149+ """Test ManualRetryResponseModel with missing id field"""
150+ # Arrange & Act & Assert
151+ with pytest .raises (ValidationError ) as exc_info :
152+ ManualRetryResponseModel (status = StateStatusEnum .CREATED ) # type: ignore
153+
154+ assert "id" in str (exc_info .value )
155+ assert "Field required" in str (exc_info .value )
156+
157+ def test_manual_retry_response_model_missing_status (self ):
158+ """Test ManualRetryResponseModel with missing status field"""
159+ # Arrange & Act & Assert
160+ with pytest .raises (ValidationError ) as exc_info :
161+ ManualRetryResponseModel (id = "507f1f77bcf86cd799439011" ) # type: ignore
162+
163+ assert "status" in str (exc_info .value )
164+ assert "Field required" in str (exc_info .value )
165+
166+ def test_manual_retry_response_model_none_id (self ):
167+ """Test ManualRetryResponseModel with None id"""
168+ # Arrange & Act & Assert
169+ with pytest .raises (ValidationError ) as exc_info :
170+ ManualRetryResponseModel (id = None , status = StateStatusEnum .CREATED ) # type: ignore
171+
172+ assert "id" in str (exc_info .value )
173+
174+ def test_manual_retry_response_model_none_status (self ):
175+ """Test ManualRetryResponseModel with None status"""
176+ # Arrange & Act & Assert
177+ with pytest .raises (ValidationError ) as exc_info :
178+ ManualRetryResponseModel (id = "507f1f77bcf86cd799439011" , status = None ) # type: ignore
179+
180+ assert "status" in str (exc_info .value )
181+
182+ def test_manual_retry_response_model_invalid_status (self ):
183+ """Test ManualRetryResponseModel with invalid status"""
184+ # Arrange & Act & Assert
185+ with pytest .raises (ValidationError ) as exc_info :
186+ ManualRetryResponseModel (id = "507f1f77bcf86cd799439011" , status = "INVALID_STATUS" ) # type: ignore
187+
188+ assert "status" in str (exc_info .value )
189+
190+ def test_manual_retry_response_model_numeric_id (self ):
191+ """Test ManualRetryResponseModel with numeric id (should fail validation)"""
192+ # Arrange & Act & Assert
193+ with pytest .raises (ValidationError ) as exc_info :
194+ ManualRetryResponseModel (id = 12345 , status = StateStatusEnum .CREATED ) # type: ignore
195+
196+ assert "string_type" in str (exc_info .value )
197+
198+ def test_manual_retry_response_model_dict_representation (self ):
199+ """Test ManualRetryResponseModel dict representation"""
200+ # Arrange & Act
201+ state_id = "507f1f77bcf86cd799439011"
202+ status = StateStatusEnum .CREATED
203+ model = ManualRetryResponseModel (id = state_id , status = status )
204+
205+ # Assert
206+ expected_dict = {"id" : state_id , "status" : status }
207+ assert model .model_dump () == expected_dict
208+
209+ def test_manual_retry_response_model_json_serialization (self ):
210+ """Test ManualRetryResponseModel JSON serialization"""
211+ # Arrange & Act
212+ state_id = "507f1f77bcf86cd799439011"
213+ status = StateStatusEnum .CREATED
214+ model = ManualRetryResponseModel (id = state_id , status = status )
215+
216+ # Assert
217+ json_str = model .model_dump_json ()
218+ assert f'"id":"{ state_id } "' in json_str
219+ assert f'"status":"{ status .value } "' in json_str
220+
221+ def test_manual_retry_response_model_empty_id (self ):
222+ """Test ManualRetryResponseModel with empty string id"""
223+ # Arrange & Act
224+ state_id = ""
225+ status = StateStatusEnum .CREATED
226+ model = ManualRetryResponseModel (id = state_id , status = status )
227+
228+ # Assert
229+ assert model .id == state_id
230+ assert model .status == status
231+
232+ def test_manual_retry_response_model_long_id (self ):
233+ """Test ManualRetryResponseModel with very long id"""
234+ # Arrange & Act
235+ state_id = "a" * 1000 # Very long string
236+ status = StateStatusEnum .CREATED
237+ model = ManualRetryResponseModel (id = state_id , status = status )
238+
239+ # Assert
240+ assert model .id == state_id
241+ assert model .status == status
0 commit comments