Exemplo n.º 1
0
def test_get_components():
    set_instance("test-instance", "test", "/tmp/isomer-test")
    frontend_root, frontend_target = get_frontend_locations(False)

    component_folder = os.path.join(frontend_root, "src", "components")
    generate_component_folders(component_folder)

    components = get_components(frontend_root)
    assert isinstance(components, dict)

    assert 'test' in components
Exemplo n.º 2
0
def generate_api(ctx, filename):
    """Generate and output isomer async api definition"""

    _ = get_components("")

    api = generate_asyncapi()

    if filename == "":
        print(api)
    else:
        with open(filename, "w") as f:
            json.dump(api, f, indent=4)
Exemplo n.º 3
0
def test_update_frontends():
    set_instance("test-instance", "test", "/tmp/isomer-test")
    frontend_root, frontend_target = get_frontend_locations(False)

    component_folder = os.path.join(frontend_root, "src", "components")
    generate_component_folders(component_folder)

    components = get_components(frontend_root)

    installation_packages, imports = update_frontends(components,
                                                      frontend_root, True)

    assert "test-npm-update" in installation_packages
    assert "import test from './components/test/test.module';\n" \
           "modules.push(test);\n" in imports
Exemplo n.º 4
0
def test_install_dependencies():
    pytest.reset_base()

    frontend_root, frontend_target = get_frontend_locations(True)

    component_folder = os.path.join(frontend_root, "src", "components")
    generate_component_folders(component_folder)

    components = get_components(frontend_root)

    installation_packages, imports = update_frontends(components, frontend_root, True)

    installation_packages += get_sails_dependencies(frontend_root)
    install_dependencies(installation_packages, frontend_root)

    target = os.path.join(frontend_root, "node_modules")

    assert os.path.exists(target)
    assert os.path.exists(os.path.join(target, "test-npm-update"))
Exemplo n.º 5
0
def test_rebuild_frontend():
    pytest.reset_base()

    frontend_root, frontend_target = get_frontend_locations(True)

    component_folder = os.path.join(frontend_root, "src", "components")
    generate_component_folders(component_folder)

    components = get_components(frontend_root)

    installation_packages, imports = update_frontends(components, frontend_root, True)

    installation_packages += get_sails_dependencies(frontend_root)
    install_dependencies(installation_packages, frontend_root)

    write_main(imports, frontend_root)

    install_frontend(True, True, True, "build")

    assert os.path.exists(frontend_target)
    assert os.path.exists(os.path.join(frontend_target, "index.html"))
    assert os.path.exists(os.path.join(frontend_target, "assets"))