Exemple #1
0
def test_registry__register_extensions(registry_fixture):
    registry = Registry(registry_filename=TEST_FILENAME)
    clear_extensions(registry)
    extension = DEFAULT_REGISTRY["extensions"][0]
    registry.register_extension(extension)
    extensions = registry.list_extensions()
    assert len(extensions) == 1
    ext = extensions[0]

    assert ext["name"] == extension["name"]
    cfg_class = registry.get_extension_class(ext["name"],
                                             ExtensionClassType.CONFIGURATION)
    assert cfg_class == GenericCommandConfiguration
    exec_class = registry.get_extension_class(ext["name"],
                                              ExtensionClassType.EXECUTION)
    assert exec_class == GenericCommandExecution
    cli_mod = registry.get_extension_class(ext["name"], ExtensionClassType.CLI)
    assert cli_mod == cli

    # Test that the the changes are reflected with a new instance.
    registry2 = Registry(registry_filename=TEST_FILENAME)
    extensions1 = registry.list_extensions()
    extensions2 = registry2.list_extensions()
    for ext1, ext2 in zip(extensions1, extensions2):
        for field in DEFAULT_REGISTRY["extensions"][0]:
            assert ext1[field] == ext2[field]
Exemple #2
0
def test_registry__reset_defaults(registry_fixture):
    registry = Registry(registry_filename=TEST_FILENAME)
    clear_extensions(registry)
    registry.reset_defaults()
    assert len(registry.list_extensions()) == len(
        DEFAULT_REGISTRY["extensions"])
    assert registry.list_loggers() == DEFAULT_REGISTRY["logging"]
Exemple #3
0
def test_registry__list_extensions(registry_fixture):
    registry = Registry(registry_filename=TEST_FILENAME)
    registry.reset_defaults()
    assert len(registry.list_extensions()) == len(
        DEFAULT_REGISTRY["extensions"])