Skip to content

Commit

Permalink
feat(fal-file-no-scale): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badayvedat committed Nov 12, 2024
1 parent 06161be commit 882171d
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions projects/fal/tests/cli/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def mock_args(
app_name: Optional[str] = None,
auth: Optional[str] = None,
strategy: Optional[str] = None,
no_scale: bool = False,
):
args = MagicMock()

Expand All @@ -42,6 +43,8 @@ def mock_args(
args.auth = auth
args.strategy = strategy

args.no_scale = no_scale

return args


Expand All @@ -67,6 +70,7 @@ def test_deploy_with_toml_success(
args,
"shared",
"rolling",
False,
)


Expand All @@ -92,6 +96,7 @@ def test_deploy_with_toml_no_auth(
args,
"private",
"recreate",
False,
)


Expand Down Expand Up @@ -185,6 +190,7 @@ def test_deploy_with_toml_deployment_strategy(
args,
"shared",
"rolling",
False,
)


Expand All @@ -208,6 +214,7 @@ def test_deploy_with_toml_default_deployment_strategy(
args,
"private",
"recreate",
False,
)


Expand All @@ -229,6 +236,7 @@ def test_deploy_with_cli_auth(
args,
"shared",
None,
False,
)


Expand All @@ -250,4 +258,49 @@ def test_deploy_with_cli_deployment_strategy(
args,
None,
"rolling",
False,
)


@patch("fal.cli._utils.find_pyproject_toml", return_value="pyproject.toml")
@patch("fal.cli._utils.parse_pyproject_toml")
@patch("fal.cli.deploy._deploy_from_reference")
def test_deploy_with_cli_no_scale(
mock_deploy_ref, mock_parse_toml, mock_find_toml, mock_parse_pyproject_toml
):
mock_parse_toml.return_value = mock_parse_pyproject_toml

args = mock_args(app_ref=("src/my_app/inference.py", "MyApp"), no_scale=True)

_deploy(args)

mock_deploy_ref.assert_called_once_with(
("src/my_app/inference.py", "MyApp"),
None,
args,
None,
None,
True,
)


@patch("fal.cli._utils.find_pyproject_toml", return_value="pyproject.toml")
@patch("fal.cli._utils.parse_pyproject_toml")
@patch("fal.cli.deploy._deploy_from_reference")
def test_deploy_with_cli_scale(
mock_deploy_ref, mock_parse_toml, mock_find_toml, mock_parse_pyproject_toml
):
mock_parse_toml.return_value = mock_parse_pyproject_toml

args = mock_args(app_ref=("src/my_app/inference.py", "MyApp"))

_deploy(args)

mock_deploy_ref.assert_called_once_with(
("src/my_app/inference.py", "MyApp"),
None,
args,
None,
None,
False,
)

0 comments on commit 882171d

Please sign in to comment.