From 8e2192a4b5423a9e50f764b7d312cb21da1ac5d6 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Mon, 10 Feb 2025 18:48:13 +0100 Subject: [PATCH] fix units test again --- reflex/utils/prerequisites.py | 2 +- tests/units/utils/test_utils.py | 22 ++-------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 8571e8c2b..fbda615bc 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -1317,7 +1317,7 @@ def validate_bun(): if not path_ops.samefile(bun_path, constants.Bun.DEFAULT_PATH): console.info(f"Using custom Bun path: {bun_path}") bun_version = get_bun_version() - if not bun_version: + if bun_version is None: console.error( "Failed to obtain bun version. Make sure the specified bun path in your config is correct." ) diff --git a/tests/units/utils/test_utils.py b/tests/units/utils/test_utils.py index 8123d8ca5..55cc70885 100644 --- a/tests/units/utils/test_utils.py +++ b/tests/units/utils/test_utils.py @@ -126,39 +126,22 @@ def test_validate_none_bun_path(mocker): prerequisites.validate_bun() -@pytest.mark.parametrize( - "exists,samefile", - [ - (False, None), - (True, False), - ], -) def test_validate_invalid_bun_path( - exists, - samefile, mocker, ): """Test that an error is thrown when a custom specified bun path is not valid or does not exist. Args: - exists: Whether the bun path exists. - samefile: Whether the bun path is the same file. mocker: Pytest mocker object. """ mock_path = mocker.Mock() - mock_path.exists.return_value = exists - mock_path.samefile.return_value = samefile mocker.patch("reflex.utils.path_ops.get_bun_path", return_value=mock_path) + mocker.patch("reflex.utils.path_ops.samefile", return_value=False) mocker.patch("reflex.utils.prerequisites.get_bun_version", return_value=None) with pytest.raises(typer.Exit): prerequisites.validate_bun() - mock_path.exists.assert_called_once() - if exists: - mock_path.samefile.assert_called_once() - else: - mock_path.samefile.assert_not_called() def test_validate_bun_path_incompatible_version(mocker): @@ -170,6 +153,7 @@ def test_validate_bun_path_incompatible_version(mocker): mock_path = mocker.Mock() mock_path.samefile.return_value = False mocker.patch("reflex.utils.path_ops.get_bun_path", return_value=mock_path) + mocker.patch("reflex.utils.path_ops.samefile", return_value=False) mocker.patch( "reflex.utils.prerequisites.get_bun_version", return_value=version.parse("0.6.5"), @@ -177,8 +161,6 @@ def test_validate_bun_path_incompatible_version(mocker): with pytest.raises(typer.Exit): prerequisites.validate_bun() - mock_path.exists.assert_called_once() - mock_path.samefile.assert_called_once() def test_remove_existing_bun_installation(mocker):