Przeglądaj źródła

Remove Home folder for windows (#1502)

Elijah Ahianyo 1 rok temu
rodzic
commit
a9b7394e0e
3 zmienionych plików z 28 dodań i 2 usunięć
  1. 1 1
      reflex/__init__.py
  2. 2 1
      reflex/utils/prerequisites.py
  3. 25 0
      tests/test_utils.py

+ 1 - 1
reflex/__init__.py

@@ -1,7 +1,7 @@
 """Import all classes and functions the end user will need to make an app.
 
 Anything imported here will be available in the default Reflex import as `rx.*`.
-To signal to typecheckers that something should be reexported, 
+To signal to typecheckers that something should be reexported,
 we use the Flask "import name as name" syntax.
 """
 

+ 2 - 1
reflex/utils/prerequisites.py

@@ -438,7 +438,8 @@ def is_latest_template() -> bool:
 def initialize_frontend_dependencies():
     """Initialize all the frontend dependencies."""
     # Create the reflex directory.
-    path_ops.mkdir(constants.REFLEX_DIR)
+    if not IS_WINDOWS:
+        path_ops.mkdir(constants.REFLEX_DIR)
 
     # Install the frontend dependencies.
     processes.run_concurrently(install_node, install_bun)

+ 25 - 0
tests/test_utils.py

@@ -558,3 +558,28 @@ def test_bun_install_without_unzip(mocker):
 
     with pytest.raises(FileNotFoundError):
         prerequisites.install_bun()
+
+
+# from
+@pytest.mark.parametrize("is_windows", [True, False])
+def test_create_reflex_dir(mocker, is_windows):
+    """Test that a reflex directory is created on initializing frontend
+    dependencies.
+
+    Args:
+        mocker: Pytest mocker object.
+        is_windows: Whether platform is windows.
+    """
+    mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", is_windows)
+    mocker.patch("reflex.utils.prerequisites.processes.run_concurrently", mocker.Mock())
+    mocker.patch("reflex.utils.prerequisites.initialize_web_directory", mocker.Mock())
+    create_cmd = mocker.patch(
+        "reflex.utils.prerequisites.path_ops.mkdir", mocker.Mock()
+    )
+
+    prerequisites.initialize_frontend_dependencies()
+
+    if is_windows:
+        assert not create_cmd.called
+    else:
+        assert create_cmd.called