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_install(driver, display, victory):
display(victory.Import("VictoryBar"))
driver.find_element_by_class_name("VictoryContainer")
assert client.web_module_exists("victory")
assert client.web_module_url("victory") == "../web_modules/victory.js"
def test_module_deletion():
# also test install
jquery = idom.Module("jquery", install="jquery@3.5.0")
assert idom.client.web_module_exists(jquery.name)
with idom.client.web_module_path(jquery.name).open() as f:
assert "jQuery JavaScript Library v3.5.0" in f.read()
jquery.delete()
assert not idom.client.web_module_exists(jquery.name)
def test_custom_module(driver, display, victory):
my_chart = Module("my/chart", source=HERE / "my_chart.js")
assert client.web_module_exists("my/chart")
assert client.web_module_url("my/chart") == "../web_modules/my/chart.js"
display(my_chart.Import("Chart"))
driver.find_element_by_class_name("VictoryContainer")
my_chart.delete()
assert not client.web_module_exists("my/chart")
def test_bad_subprocess_call(subprocess_run, caplog):
with pytest.raises(CalledProcessError):
client.install(["victory"])
assert "an error occured" in caplog.text
def test_module_deletion():
# also test install
jquery = idom.Module("jquery", install="jquery@3.5.0")
assert idom.client.web_module_exists(jquery.name)
with idom.client.web_module_path(jquery.name).open() as f:
assert "jQuery JavaScript Library v3.5.0" in f.read()
jquery.delete()
assert not idom.client.web_module_exists(jquery.name)
def test_restore(capsys):
main("restore")
assert client.installed() == ["htm", "react", "react-dom"]
def __init__(
self,
name: str,
install: Union[bool, str] = False,
source: Optional[Union[str, Path]] = None,
replace: bool = False,
) -> None:
self._installed = False
if install and source:
raise ValueError("Both 'install' and 'source' were given.")
elif (install or source) and not replace and client.web_module_exists(name):
self._module = client.web_module_url(name)
self._installed = True
self._name = name
elif source is not None:
self._module = client.register_web_module(name, source)
self._installed = True
self._name = name
elif isinstance(install, str):
client.install([install], [name])
self._module = client.web_module_url(name)
self._installed = True
self._name = name
elif install is True:
client.install(name)
self._module = client.web_module_url(name)
self._installed = True
elif source is not None:
self._module = client.register_web_module(name, source)
self._installed = True
self._name = name
elif isinstance(install, str):
client.install([install], [name])
self._module = client.web_module_url(name)
self._installed = True
self._name = name
elif install is True:
client.install(name)
self._module = client.web_module_url(name)
self._installed = True
self._name = name
elif client.web_module_exists(name):
self._module = client.web_module_url(name)
else:
self._module = name