Beispiel #1
0
def test_monkeypatch_megacomplexes():
    """Megacomplex only added to registry while context is entered."""
    with monkeypatch_plugin_registry_megacomplex(
            test_megacomplex={"test_mc": DummyMegacomplex}):
        assert "test_mc" in known_megacomplex_names()

    assert "test_mc" not in known_megacomplex_names()
    with monkeypatch_plugin_registry(
            test_megacomplex={"test_full": DummyMegacomplex}):
        assert "test_full" in known_megacomplex_names()

    assert "test_full" not in known_megacomplex_names()
Beispiel #2
0
def test_monkeypatch_plugin_registry_full(create_new_registry: bool):
    """Create a completely new registry."""

    assert "decay" in known_megacomplex_names()
    assert "yml" in known_project_formats()
    assert "sdt" in known_data_formats()

    with monkeypatch_plugin_registry(
            test_megacomplex={"test_mc": DummyMegacomplex},
            test_project_io={"test_pio": DummyProjectIo(format_name="test")},
            test_data_io={"test_dio": DummyDataIo(format_name="test")},
            create_new_registry=create_new_registry,
    ):
        assert "test_mc" in known_megacomplex_names()
        assert "test_pio" in known_project_formats()
        assert "test_dio" in known_data_formats()
        assert ("decay"
                not in known_megacomplex_names()) is create_new_registry
        assert ("yml" not in known_project_formats()) is create_new_registry
        assert ("sdt" not in known_data_formats()) is create_new_registry
Beispiel #3
0
def test_monkeypatch_project_io():
    """ProjectIoInterface only added to registry while context is entered."""
    with monkeypatch_plugin_registry_project_io(
            test_project_io={"test_pio": DummyProjectIo(format_name="test")}):
        assert "test_pio" in known_project_formats()

    assert "test_pio" not in known_megacomplex_names()
    with monkeypatch_plugin_registry(
            test_project_io={"test_full": DummyProjectIo(format_name="test")}):
        assert "test_full" in known_project_formats()

    assert "test_full" not in known_project_formats()
def test_register_megacomplex():
    """Register new megacomplex."""
    register_megacomplex("base-megacomplex", Megacomplex)

    assert "base-megacomplex" in __PluginRegistry.megacomplex
    assert __PluginRegistry.megacomplex["base-megacomplex"] == Megacomplex
    assert "glotaran.model.megacomplex.Megacomplex" in __PluginRegistry.megacomplex
    assert __PluginRegistry.megacomplex[
        "glotaran.model.megacomplex.Megacomplex"] == Megacomplex
    assert known_megacomplex_names(full_names=True) == sorted([
        "foo",
        "bar",
        "glotaran.builtin.megacomplexes.decay.DecayMegacomplex",
        "base-megacomplex",
        "glotaran.model.megacomplex.Megacomplex",
    ])
Beispiel #5
0
def plugin_list_cmd():
    """Prints a list of installed plugins."""

    output = dedent("""
        Installed Glotaran Plugins:

        Megacomplex Models:
        """)
    output += "\n"

    for name in known_megacomplex_names():
        output += f"    * {name}\n"

    output += "\nData file Formats\n\n"

    for reader_fmt in known_data_formats():
        output += f"    * .{reader_fmt}\n"

    output += "\nProject file Formats\n\n"

    for reader_fmt in known_project_formats():
        output += f"    * .{reader_fmt}\n"

    click.echo(output)
def test_known_megacomplex_names():
    """Get megacomplex names from registry"""
    assert known_megacomplex_names() == sorted(["foo", "bar"])