@@ -67,17 +67,23 @@ def test_serve_default_options(
67
67
assert result .exit_code == 0
68
68
mock_setup_logging .assert_called_once_with (LogLevel .INFO , LogFormat .JSON )
69
69
mock_logging .assert_called_with ("codegate" )
70
- logger_instance .info .assert_any_call (
71
- "Starting server" ,
72
- extra = {
73
- "host" : "localhost" ,
74
- "port" : 8989 ,
75
- "log_level" : "INFO" ,
76
- "log_format" : "JSON" ,
77
- "prompts_loaded" : 6 , # Default prompts are loaded
78
- "provider_urls" : DEFAULT_PROVIDER_URLS ,
79
- },
80
- )
70
+
71
+ # validate only a subset of the expected extra arguments, as image provides more
72
+ expected_extra = {
73
+ "host" : "localhost" ,
74
+ "port" : 8989 ,
75
+ "log_level" : "INFO" ,
76
+ "log_format" : "JSON" ,
77
+ "prompts_loaded" : 6 ,
78
+ "provider_urls" : DEFAULT_PROVIDER_URLS ,
79
+ }
80
+
81
+ # Retrieve the actual call arguments
82
+ calls = [call [1 ]['extra' ] for call in logger_instance .info .call_args_list ]
83
+
84
+ # Check if one of the calls matches the expected subset
85
+ assert any (all (expected_extra [k ] == actual_extra .get (k )
86
+ for k in expected_extra ) for actual_extra in calls )
81
87
mock_run .assert_called_once ()
82
88
83
89
@@ -106,17 +112,22 @@ def test_serve_custom_options(
106
112
assert result .exit_code == 0
107
113
mock_setup_logging .assert_called_once_with (LogLevel .DEBUG , LogFormat .TEXT )
108
114
mock_logging .assert_called_with ("codegate" )
109
- logger_instance .info .assert_any_call (
110
- "Starting server" ,
111
- extra = {
112
- "host" : "localhost" ,
113
- "port" : 8989 ,
114
- "log_level" : "DEBUG" ,
115
- "log_format" : "TEXT" ,
116
- "prompts_loaded" : 6 , # Default prompts are loaded
117
- "provider_urls" : DEFAULT_PROVIDER_URLS ,
118
- },
119
- )
115
+
116
+ # Retrieve the actual call arguments
117
+ calls = [call [1 ]['extra' ] for call in logger_instance .info .call_args_list ]
118
+
119
+ expected_extra = {
120
+ "host" : "localhost" ,
121
+ "port" : 8989 ,
122
+ "log_level" : "DEBUG" ,
123
+ "log_format" : "TEXT" ,
124
+ "prompts_loaded" : 6 , # Default prompts are loaded
125
+ "provider_urls" : DEFAULT_PROVIDER_URLS ,
126
+ }
127
+
128
+ # Check if one of the calls matches the expected subset
129
+ assert any (all (expected_extra [k ] == actual_extra .get (k )
130
+ for k in expected_extra ) for actual_extra in calls )
120
131
mock_run .assert_called_once ()
121
132
122
133
@@ -146,17 +157,22 @@ def test_serve_with_config_file(
146
157
assert result .exit_code == 0
147
158
mock_setup_logging .assert_called_once_with (LogLevel .DEBUG , LogFormat .JSON )
148
159
mock_logging .assert_called_with ("codegate" )
149
- logger_instance .info .assert_any_call (
150
- "Starting server" ,
151
- extra = {
152
- "host" : "localhost" ,
153
- "port" : 8989 ,
154
- "log_level" : "DEBUG" ,
155
- "log_format" : "JSON" ,
156
- "prompts_loaded" : 6 , # Default prompts are loaded
157
- "provider_urls" : DEFAULT_PROVIDER_URLS ,
158
- },
159
- )
160
+
161
+ # Retrieve the actual call arguments
162
+ calls = [call [1 ]['extra' ] for call in logger_instance .info .call_args_list ]
163
+
164
+ expected_extra = {
165
+ "host" : "localhost" ,
166
+ "port" : 8989 ,
167
+ "log_level" : "DEBUG" ,
168
+ "log_format" : "JSON" ,
169
+ "prompts_loaded" : 6 , # Default prompts are loaded
170
+ "provider_urls" : DEFAULT_PROVIDER_URLS ,
171
+ }
172
+
173
+ # Check if one of the calls matches the expected subset
174
+ assert any (all (expected_extra [k ] == actual_extra .get (k )
175
+ for k in expected_extra ) for actual_extra in calls )
160
176
mock_run .assert_called_once ()
161
177
162
178
@@ -198,17 +214,22 @@ def test_serve_priority_resolution(
198
214
assert result .exit_code == 0
199
215
mock_setup_logging .assert_called_once_with (LogLevel .ERROR , LogFormat .TEXT )
200
216
mock_logging .assert_called_with ("codegate" )
201
- logger_instance .info .assert_any_call (
202
- "Starting server" ,
203
- extra = {
204
- "host" : "example.com" ,
205
- "port" : 8080 ,
206
- "log_level" : "ERROR" ,
207
- "log_format" : "TEXT" ,
208
- "prompts_loaded" : 6 , # Default prompts are loaded
209
- "provider_urls" : DEFAULT_PROVIDER_URLS ,
210
- },
211
- )
217
+
218
+ # Retrieve the actual call arguments
219
+ calls = [call [1 ]['extra' ] for call in logger_instance .info .call_args_list ]
220
+
221
+ expected_extra = {
222
+ "host" : "example.com" ,
223
+ "port" : 8080 ,
224
+ "log_level" : "ERROR" ,
225
+ "log_format" : "TEXT" ,
226
+ "prompts_loaded" : 6 , # Default prompts are loaded
227
+ "provider_urls" : DEFAULT_PROVIDER_URLS ,
228
+ }
229
+
230
+ # Check if one of the calls matches the expected subset
231
+ assert any (all (expected_extra [k ] == actual_extra .get (k )
232
+ for k in expected_extra ) for actual_extra in calls )
212
233
mock_run .assert_called_once ()
213
234
214
235
0 commit comments