File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,9 @@ def generate(
123123 raise typer .BadParameter ("client_id must be provided as an option or via the FIREFLY_CLIENT_ID environment variable." )
124124 if not client_secret :
125125 raise typer .BadParameter ("client_secret must be provided as an option or via the FIREFLY_CLIENT_SECRET environment variable." )
126+ if num_variations is not None and not (1 <= num_variations <= 4 ):
127+ typer .secho ("--num-variations must be between 1 and 4" , fg = typer .colors .RED , err = True )
128+ raise typer .Exit (code = - 1 )
126129 # Parse JSON for style/structure if provided
127130 style_obj = None
128131 if style :
Original file line number Diff line number Diff line change @@ -219,3 +219,33 @@ def test_generate_invalid_json_structure(monkeypatch):
219219 )
220220 assert result .exit_code == 2
221221 assert "Invalid JSON for --structure" in result .output
222+
223+ def test_generate_invalid_num_variations (monkeypatch ):
224+ # Test too low
225+ result = runner .invoke (
226+ app ,
227+ [
228+ "image" , "generate" ,
229+ "--client-id" , "dummy_id" ,
230+ "--client-secret" , "dummy_secret" ,
231+ "--prompt" , "test" ,
232+ "--num-variations" , "0" ,
233+ "--use-mocks"
234+ ]
235+ )
236+ assert result .exit_code == - 1
237+ assert "--num-variations must be between 1 and 4" in result .output
238+ # Test too high
239+ result = runner .invoke (
240+ app ,
241+ [
242+ "image" , "generate" ,
243+ "--client-id" , "dummy_id" ,
244+ "--client-secret" , "dummy_secret" ,
245+ "--prompt" , "test" ,
246+ "--num-variations" , "5" ,
247+ "--use-mocks"
248+ ]
249+ )
250+ assert result .exit_code == - 1
251+ assert "--num-variations must be between 1 and 4" in result .output
You can’t perform that action at this time.
0 commit comments