@@ -115,16 +115,26 @@ def test_generate_meta(self, _create_new_client):
115
115
116
116
def test_generate_encoding (self , _create_new_client ):
117
117
path = "cool/path"
118
- encoding = "utf-8"
118
+ file_encoding = "utf-8"
119
119
from openapi_python_client .cli import MetaType , app
120
120
121
- result = runner .invoke (app , ["generate" , f"--path={ path } " , f"--file-encoding={ encoding } " ])
121
+ result = runner .invoke (app , ["generate" , f"--path={ path } " , f"--file-encoding={ file_encoding } " ])
122
122
123
123
assert result .exit_code == 0
124
124
_create_new_client .assert_called_once_with (
125
125
url = None , path = Path (path ), custom_template_path = None , meta = MetaType .POETRY , file_encoding = "utf-8"
126
126
)
127
127
128
+ def test_generate_encoding_errors (self , _create_new_client ):
129
+ path = "cool/path"
130
+ file_encoding = "error-file-encoding"
131
+ from openapi_python_client .cli import MetaType , app
132
+
133
+ result = runner .invoke (app , ["generate" , f"--path={ path } " , f"--file-encoding={ file_encoding } " ])
134
+
135
+ assert result .exit_code == 1
136
+ assert result .output == "Unknown encoding : {}\n " .format (file_encoding )
137
+
128
138
def test_generate_handle_errors (self , _create_new_client ):
129
139
_create_new_client .return_value = [GeneratorError (detail = "this is a message" )]
130
140
path = "cool/path"
@@ -207,3 +217,25 @@ def test_update_path(self, _update_existing_client):
207
217
_update_existing_client .assert_called_once_with (
208
218
url = None , path = Path (path ), custom_template_path = None , meta = MetaType .POETRY , file_encoding = "utf-8"
209
219
)
220
+
221
+ def test_update_encoding (self , _update_existing_client ):
222
+ path = "cool/path"
223
+ file_encoding = "utf-8"
224
+ from openapi_python_client .cli import MetaType , app
225
+
226
+ result = runner .invoke (app , ["update" , f"--path={ path } " , f"--file-encoding={ file_encoding } " ])
227
+
228
+ assert result .exit_code == 0
229
+ _update_existing_client .assert_called_once_with (
230
+ url = None , path = Path (path ), custom_template_path = None , meta = MetaType .POETRY , file_encoding = "utf-8"
231
+ )
232
+
233
+ def test_update_encoding_errors (self , _update_existing_client ):
234
+ path = "cool/path"
235
+ file_encoding = "error-file-encoding"
236
+ from openapi_python_client .cli import MetaType , app
237
+
238
+ result = runner .invoke (app , ["update" , f"--path={ path } " , f"--file-encoding={ file_encoding } " ])
239
+
240
+ assert result .exit_code == 1
241
+ assert result .output == "Unknown encoding : {}\n " .format (file_encoding )
0 commit comments