Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_simple_install(capsys):
client.delete_web_modules("jquery", skip_missing=True)
main("install", "jquery")
assert client.web_module_exists("jquery")
main("installed")
captured = capsys.readouterr()
assert "- jquery" in captured.out
with assert_file_is_touched(client.web_module_path("jquery")):
main("install", "jquery", "--force")
assert client.web_module_exists("jquery")
main("uninstall", "jquery")
assert not client.web_module_exists("jquery")
def test_install():
client.delete_web_modules(["jquery"], skip_missing=True)
client.install("jquery")
assert client.web_module_exists("jquery")
assert client.web_module_exists("/jquery") # works with a leading slash too
assert "jquery" in client.installed()
with assert_file_is_touched(client.web_module_path("jquery")):
client.install("jquery", force=True)
with pytest.raises(ValueError, match="already exists"):
# can't register a module with the same name
client.register_web_module("jquery", Path() / "some-module.js")
client.delete_web_modules("jquery")
assert not client.web_module_exists("jquery")
assert "jquery" not in client.installed()
def test_install_with_exports(capsys):
client.delete_web_modules(["preact", "preact/hooks"], skip_missing=True)
main("install", "preact", "--exports", "preact/hooks")
assert client.web_module_exists("preact/hooks")
main("installed")
captured = capsys.readouterr()
assert "- preact" in captured.out
assert "- preact/hooks" in captured.out
main("uninstall", "preact")
assert not client.web_module_exists("preact/hooks")
main("installed")
captured = capsys.readouterr()
assert "- preact" not in captured.out
assert "- preact/hooks" not in captured.out
def test_install():
client.delete_web_modules(["jquery"], skip_missing=True)
client.install("jquery")
assert client.web_module_exists("jquery")
assert client.web_module_exists("/jquery") # works with a leading slash too
assert "jquery" in client.installed()
with assert_file_is_touched(client.web_module_path("jquery")):
client.install("jquery", force=True)
with pytest.raises(ValueError, match="already exists"):
# can't register a module with the same name
client.register_web_module("jquery", Path() / "some-module.js")
client.delete_web_modules("jquery")
assert not client.web_module_exists("jquery")
assert "jquery" not in client.installed()
def delete(self) -> None:
if not self._installed:
raise ValueError("Module is not installed locally")
client.delete_web_modules([self._name])