|
6 | 6 |
|
7 | 7 | import pytest
|
8 | 8 | import respx
|
| 9 | +from click.testing import Result |
9 | 10 | from fastapi_cli.cli import app
|
10 | 11 | from fastapi_cli.config import settings
|
11 | 12 | from httpx import Response
|
@@ -449,10 +450,7 @@ def test_returns_error_when_team_not_found(
|
449 | 450 | assert result.exit_code == 1
|
450 | 451 |
|
451 | 452 |
|
452 |
| -@pytest.mark.respx(base_url=settings.base_api_url) |
453 |
| -def test_can_skip_waiting( |
454 |
| - logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter |
455 |
| -) -> None: |
| 453 | +def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Result: |
456 | 454 | steps = [ENTER, ENTER, ENTER, *"demo", ENTER]
|
457 | 455 |
|
458 | 456 | team_data = _get_random_team()
|
@@ -499,8 +497,55 @@ def test_can_skip_waiting(
|
499 | 497 | with changing_dir(tmp_path), patch("click.getchar") as mock_getchar:
|
500 | 498 | mock_getchar.side_effect = steps
|
501 | 499 |
|
502 |
| - result = runner.invoke(app, ["deploy", "--no-wait"]) |
| 500 | + return runner.invoke(app, ["deploy", "--no-wait"]) |
503 | 501 |
|
504 |
| - assert result.exit_code == 0 |
505 | 502 |
|
506 |
| - assert "Check the status of your deployment at" in result.output |
| 503 | +@pytest.mark.respx(base_url=settings.base_api_url) |
| 504 | +def test_can_skip_waiting( |
| 505 | + logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter |
| 506 | +) -> None: |
| 507 | + result = _deploy_without_waiting(respx_mock, tmp_path) |
| 508 | + |
| 509 | + assert result.exit_code == 0 |
| 510 | + |
| 511 | + assert "Check the status of your deployment at" in result.output |
| 512 | + |
| 513 | + |
| 514 | +@pytest.mark.respx(base_url=settings.base_api_url) |
| 515 | +def test_creates_config_folder_and_adds_it_to_gitignore( |
| 516 | + logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter |
| 517 | +) -> None: |
| 518 | + git_ignore_path = tmp_path / ".gitignore" |
| 519 | + git_ignore_path.write_text(".venv\n") |
| 520 | + |
| 521 | + _deploy_without_waiting(respx_mock, tmp_path) |
| 522 | + |
| 523 | + assert (tmp_path / ".fastapi" / "cloud.json").exists() |
| 524 | + assert (tmp_path / ".fastapi" / "README.md").exists() |
| 525 | + |
| 526 | + assert git_ignore_path.read_text() == ".venv\n.fastapi\n" |
| 527 | + |
| 528 | + |
| 529 | +@pytest.mark.respx(base_url=settings.base_api_url) |
| 530 | +def test_creates_config_folder_and_creates_git_ignore( |
| 531 | + logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter |
| 532 | +) -> None: |
| 533 | + _deploy_without_waiting(respx_mock, tmp_path) |
| 534 | + |
| 535 | + assert (tmp_path / ".fastapi" / "cloud.json").exists() |
| 536 | + assert (tmp_path / ".fastapi" / "README.md").exists() |
| 537 | + assert (tmp_path / ".gitignore").exists() |
| 538 | + |
| 539 | + assert (tmp_path / ".gitignore").read_text() == ".fastapi\n" |
| 540 | + |
| 541 | + |
| 542 | +@pytest.mark.respx(base_url=settings.base_api_url) |
| 543 | +def test_does_not_duplicate_entry_in_git_ignore( |
| 544 | + logged_in_cli: None, tmp_path: Path, respx_mock: respx.MockRouter |
| 545 | +) -> None: |
| 546 | + git_ignore_path = tmp_path / ".gitignore" |
| 547 | + git_ignore_path.write_text(".fastapi\n") |
| 548 | + |
| 549 | + _deploy_without_waiting(respx_mock, tmp_path) |
| 550 | + |
| 551 | + assert git_ignore_path.read_text() == ".fastapi\n" |
0 commit comments