Пример #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_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")
Пример #3
0
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")
Пример #4
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"
Пример #5
0
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
Пример #6
0
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()
Пример #7
0
def test_delete_module(victory):
    victory.delete()
    assert not client.web_module_exists("victory")

    with pytest.raises(ValueError, match="does not exist"):
        victory.delete()
Пример #8
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