Example #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
Example #2
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
Example #3
0
def test_generate_component_folders():
    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)

    assert os.path.exists(component_folder)

    old_file = os.path.join(component_folder, "ham")

    with open(old_file, "w") as f:
        f.write("spam")

    generate_component_folders(component_folder)

    assert not os.path.exists(old_file)
Example #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"))
Example #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"))