Skip to content

Commit babb83b

Browse files
authored
Merge branch 'main' into dependabot/pip/mypy-1.18.1
2 parents 29791ee + cc536ee commit babb83b

File tree

4 files changed

+47
-17
lines changed

4 files changed

+47
-17
lines changed

release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
* 🧑‍💻 Handle HTTP errors when streaming build logs. PR [#65](https://github.com/fastapilabs/fastapi-cloud-cli/pull/65) by [@patrick91](https://github.com/patrick91).
88

9+
### Refactors
10+
11+
* ✅ Fix mocks in tests . PR [#78](https://github.com/fastapilabs/fastapi-cloud-cli/pull/78) by [@alejsdev](https://github.com/alejsdev).
12+
913
## 0.1.4
1014

1115
### Fixes

tests/test_cli_deploy.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_shows_waitlist_form_when_not_logged_in(
8080
).mock(return_value=Response(200))
8181

8282
with changing_dir(tmp_path), patch(
83-
"rich_toolkit.menu.click.getchar"
83+
"rich_toolkit.container.getchar"
8484
) as mock_getchar:
8585
mock_getchar.side_effect = steps
8686

@@ -138,7 +138,7 @@ def test_shows_waitlist_form_when_not_logged_in_longer_flow(
138138
).mock(return_value=Response(200))
139139

140140
with changing_dir(tmp_path), patch(
141-
"rich_toolkit.menu.click.getchar"
141+
"rich_toolkit.container.getchar"
142142
) as mock_getchar:
143143
mock_getchar.side_effect = steps
144144

@@ -153,7 +153,7 @@ def test_asks_to_setup_the_app(logged_in_cli: None, tmp_path: Path) -> None:
153153
steps = [Keys.RIGHT_ARROW, Keys.ENTER]
154154

155155
with changing_dir(tmp_path), patch(
156-
"rich_toolkit.menu.click.getchar"
156+
"rich_toolkit.container.getchar"
157157
) as mock_getchar:
158158
mock_getchar.side_effect = steps
159159

@@ -171,7 +171,9 @@ def test_shows_error_when_trying_to_get_teams(
171171

172172
respx_mock.get("/teams/").mock(return_value=Response(500))
173173

174-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
174+
with changing_dir(tmp_path), patch(
175+
"rich_toolkit.container.getchar"
176+
) as mock_getchar:
175177
mock_getchar.side_effect = steps
176178

177179
result = runner.invoke(app, ["deploy"])
@@ -189,7 +191,9 @@ def test_handles_invalid_auth(
189191

190192
respx_mock.get("/teams/").mock(return_value=Response(401))
191193

192-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
194+
with changing_dir(tmp_path), patch(
195+
"rich_toolkit.container.getchar"
196+
) as mock_getchar:
193197
mock_getchar.side_effect = steps
194198

195199
result = runner.invoke(app, ["deploy"])
@@ -215,7 +219,9 @@ def test_shows_teams(
215219
)
216220
)
217221

218-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
222+
with changing_dir(tmp_path), patch(
223+
"rich_toolkit.container.getchar"
224+
) as mock_getchar:
219225
mock_getchar.side_effect = steps
220226

221227
result = runner.invoke(app, ["deploy"])
@@ -239,7 +245,9 @@ def test_asks_for_app_name_after_team(
239245
)
240246
)
241247

242-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
248+
with changing_dir(tmp_path), patch(
249+
"rich_toolkit.container.getchar"
250+
) as mock_getchar:
243251
mock_getchar.side_effect = steps
244252

245253
result = runner.invoke(app, ["deploy"])
@@ -268,7 +276,9 @@ def test_creates_app_on_backend(
268276
return_value=Response(201, json=_get_random_app(team_id=team["id"]))
269277
)
270278

271-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
279+
with changing_dir(tmp_path), patch(
280+
"rich_toolkit.container.getchar"
281+
) as mock_getchar:
272282
mock_getchar.side_effect = steps
273283

274284
result = runner.invoke(app, ["deploy"])
@@ -294,7 +304,9 @@ def test_uses_existing_app(
294304
return_value=Response(200, json={"data": [app_data]})
295305
)
296306

297-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
307+
with changing_dir(tmp_path), patch(
308+
"rich_toolkit.container.getchar"
309+
) as mock_getchar:
298310
mock_getchar.side_effect = steps
299311

300312
result = runner.invoke(app, ["deploy"])
@@ -367,7 +379,9 @@ def test_exits_successfully_when_deployment_is_done(
367379
)
368380
)
369381

370-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
382+
with changing_dir(tmp_path), patch(
383+
"rich_toolkit.container.getchar"
384+
) as mock_getchar:
371385
mock_getchar.side_effect = steps
372386

373387
result = runner.invoke(app, ["deploy"])
@@ -615,7 +629,9 @@ def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Res
615629
return_value=Response(200)
616630
)
617631

618-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
632+
with changing_dir(tmp_path), patch(
633+
"rich_toolkit.container.getchar"
634+
) as mock_getchar:
619635
mock_getchar.side_effect = steps
620636

621637
return runner.invoke(app, ["deploy", "--no-wait"])
@@ -687,7 +703,9 @@ def test_creates_environment_variables_during_app_setup(
687703
f"/apps/{app_data['id']}/environment-variables/", json={"API_KEY": "secret123"}
688704
).mock(return_value=Response(200))
689705

690-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
706+
with changing_dir(tmp_path), patch(
707+
"rich_toolkit.container.getchar"
708+
) as mock_getchar:
691709
mock_getchar.side_effect = steps
692710

693711
result = runner.invoke(app, ["deploy"])
@@ -731,7 +749,9 @@ def test_rejects_invalid_environment_variable_names(
731749
f"/apps/{app_data['id']}/environment-variables/", json={"VALID_KEY": "value123"}
732750
).mock(return_value=Response(200))
733751

734-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
752+
with changing_dir(tmp_path), patch(
753+
"rich_toolkit.container.getchar"
754+
) as mock_getchar:
735755
mock_getchar.side_effect = steps
736756

737757
result = runner.invoke(app, ["deploy"])
@@ -754,7 +774,7 @@ def test_shows_error_for_invalid_waitlist_form_data(
754774
]
755775

756776
with changing_dir(tmp_path), patch(
757-
"rich_toolkit.menu.click.getchar"
777+
"rich_toolkit.container.getchar"
758778
) as mock_getchar, patch("rich_toolkit.form.Form.run") as mock_form_run:
759779
mock_getchar.side_effect = steps
760780
# Simulate form returning data with invalid email field to trigger ValidationError
@@ -789,7 +809,9 @@ def test_shows_no_apps_found_message_when_team_has_no_apps(
789809
return_value=Response(200, json={"data": []})
790810
)
791811

792-
with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
812+
with changing_dir(tmp_path), patch(
813+
"rich_toolkit.container.getchar"
814+
) as mock_getchar:
793815
mock_getchar.side_effect = steps
794816

795817
result = runner.invoke(app, ["deploy"])

tests/test_env_delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def test_shows_selector_for_environment_variables(
122122
return_value=Response(204)
123123
)
124124

125-
with changing_dir(configured_app), patch("click.getchar", side_effect=steps):
125+
with changing_dir(configured_app), patch(
126+
"rich_toolkit.container.getchar", side_effect=steps
127+
):
126128
result = runner.invoke(app, ["env", "delete"])
127129

128130
assert result.exit_code == 0

tests/test_env_set.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def test_asks_for_name_and_value(
8686
return_value=Response(200)
8787
)
8888

89-
with changing_dir(configured_app), patch("click.getchar", side_effect=steps):
89+
with changing_dir(configured_app), patch(
90+
"rich_toolkit.container.getchar", side_effect=steps
91+
):
9092
result = runner.invoke(app, ["env", "set"])
9193

9294
assert result.exit_code == 0

0 commit comments

Comments
 (0)