MCPcopy
hub / github.com/reflex-dev/reflex / install_packages_env

Function install_packages_env

tests/units/test_prerequisites.py:90–132  ·  view source on GitHub ↗

Isolated environment for install_frontend_packages tests. Creates the web dir, patches get_web_dir, chdirs into tmp_path, and exposes the bun lock and package.json paths, a Config, a package-manager patch helper, and a runner that invokes install_frontend_packages. Framework dep con

(
    tmp_path, monkeypatch
)

Source from the content-addressed store, hash-verified

88
89@pytest.fixture
90def install_packages_env(
91 tmp_path, monkeypatch
92) -> Generator[InstallPackagesEnv, None, None]:
93 """Isolated environment for install_frontend_packages tests.
94
95 Creates the web dir, patches get_web_dir, chdirs into tmp_path, and
96 exposes the bun lock and package.json paths, a Config, a
97 package-manager patch helper, and a runner that invokes
98 install_frontend_packages. Framework dep constants are emptied so
99 tests can reason about exactly the calls they trigger.
100
101 Yields:
102 An InstallPackagesEnv with paths, config, and patch_pm/install helpers.
103 """
104 web_dir = tmp_path / constants.Dirs.WEB
105 web_dir.mkdir()
106 _patch_web_dir(monkeypatch, web_dir)
107 _stub_framework_packages(monkeypatch)
108 config = Config(app_name="test")
109
110 def patch_pm(package_managers: list[str], run_package_manager: Callable) -> None:
111 _patch_frontend_package_manager(
112 monkeypatch, package_managers, run_package_manager
113 )
114
115 def install(packages: set[str] | None = None) -> None:
116 js_runtimes.install_frontend_packages(packages or set(), config)
117
118 root_lock_dir = tmp_path / constants.Bun.ROOT_LOCKFILE_DIR
119 root_lock_dir.mkdir(parents=True, exist_ok=True)
120 env = InstallPackagesEnv(
121 tmp_path=tmp_path,
122 web_dir=web_dir,
123 root_lock=root_lock_dir / constants.Bun.LOCKFILE_PATH,
124 web_lock=web_dir / constants.Bun.LOCKFILE_PATH,
125 root_package_json=root_lock_dir / constants.PackageJson.PATH,
126 web_package_json=web_dir / constants.PackageJson.PATH,
127 config=config,
128 patch_pm=patch_pm,
129 install=install,
130 )
131 with chdir(tmp_path):
132 yield env
133
134
135_SKELETON_INITIALIZERS = (

Callers

nothing calls this directly

Calls 5

ConfigClass · 0.90
chdirClass · 0.90
_patch_web_dirFunction · 0.85
_stub_framework_packagesFunction · 0.85
InstallPackagesEnvClass · 0.85

Tested by

no test coverage detected