示例#1
0
 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
         self._name = name
     elif client.web_module_exists(name):
         self._module = client.web_module_url(name)
     else:
         self._module = name
示例#2
0
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"
示例#3
0
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")
示例#4
0
def test_raise_on_missing_import_path():
    with pytest.raises(ValueError, match="does not exist"):
        client.web_module_url("module/that/does/not/exist")
示例#5
0
def test_install_namespace_package():
    client.install("@material-ui/core")
    assert client.web_module_exists("@material-ui/core")
    expected = "../web_modules/@material-ui/core.js"
    assert client.web_module_url("@material-ui/core") == expected