Пример #1
0
def test_instance_create():
    """On a blank setup, tests if creating an instance works"""

    pytest.reset_base()

    result = pytest.run_cli(isotool, ['instance', 'create'])

    assert result.exit_code == 0

    assert os.path.exists('/tmp/isomer-test/etc/isomer/instances/' +
                          pytest.INSTANCENAME + '.conf')
Пример #2
0
def test_00_environment_clear():
    """Creates a new default instances and clears it without archiving"""
    pytest.reset_base()

    _ = pytest.run_cli(isotool, ['instance', 'create'], full_log=True)

    assert os.path.exists('/tmp/isomer-test/etc/isomer/instances/' +
                          pytest.INSTANCENAME + '.conf')
    assert not os.path.exists('/tmp/isomer-test/var/lib/isomer/' +
                              pytest.INSTANCENAME + '/green')

    result = pytest.run_cli(isotool, ['environment', 'clear', '--no-archive'])
Пример #3
0
def test_instance_info():
    """Creates a new instance and check the info command output against it"""
    pytest.reset_base()

    _ = pytest.run_cli(isotool, ['instance', 'create'])

    result = pytest.run_cli(isotool, ['instance', 'info'])

    assert result.exit_code == 0

    assert 'Instance configuration' in result.output
    assert 'Active environment' in result.output
Пример #4
0
def test_instance_clear():
    """Creates a new instances and checks if clearing it works"""
    pytest.reset_base()

    _ = pytest.run_cli(isotool, ['instance', 'create'])

    result = pytest.run_cli(isotool,
                            ['instance', 'clear', '--force', '--no-archive'])

    # TODO: Github doesn't like messing with /tmp folders, apparently. These fail
    #  completely on github, yet neither on my local dev install or a docker build.
    assert result.exit_code == 0
Пример #5
0
def test_view_no_objects():
    """"""

    pytest.reset_base()
    result = pytest.run_cli(isotool, [
        "--dbhost", pytest.DBHOST + ":" + str(pytest.DBPORT),
        "--dbname", pytest.DBNAME,
        'db', 'objects', 'view',
        "--schema", "systemconfig"
    ], full_log=True)

    print(result.output)

    assert result.exit_code == 0
    assert "Done: cli db objects view" in result.output
Пример #6
0
def test_instance_set():
    """Creates a new instances and checks if setting a parameter works"""
    pytest.reset_base()

    _ = pytest.run_cli(isotool, ['instance', 'create'])

    new_config = load_instance(pytest.INSTANCENAME)

    assert new_config['quiet'] is True

    result = pytest.run_cli(isotool, ['instance', 'set', 'quiet', 'false'])

    new_config = load_instance(pytest.INSTANCENAME)

    assert result.exit_code == 0
    assert new_config['quiet'] is False
Пример #7
0
def test_instance_list():
    """Creates two new instances and checks if the list command lists both"""
    pytest.reset_base()

    pytest.run_cli(isotool, ['--instance', 'bar', 'instance', 'create'],
                   full_log=True)
    pytest.run_cli(isotool, ['--instance', 'foo', 'instance', 'create'],
                   full_log=True)

    result = pytest.run_cli(isotool, ['instance', 'list'])

    assert result.exit_code == 0

    pprint(result.output)

    assert 'foo' in result.output
    assert 'bar' in result.output
Пример #8
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"))
Пример #9
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"))
Пример #10
0
def test_01_install():
    """Creates a new default instances and clears it without archiving"""
    pytest.reset_base(unset_instance=True)
    import os
    import pwd

    def get_username():
        """Return current username"""
        return pwd.getpwuid(os.getuid())[0]

    _ = pytest.run_cli(isotool, ['instance', 'create'], full_log=True)
    _ = pytest.run_cli(
        isotool,
        ['instance', 'set', 'user', get_username()], full_log=True)
    _ = pytest.run_cli(isotool, ['environment', 'clear', '--no-archive'],
                       full_log=True)

    # TODO: Github doesn't like messing with /tmp folders, apparently. These fail
    #  completely on github, yet neither on my local dev install or a docker build.

    # assert os.path.exists('/tmp/isomer-test/etc/isomer/instances/' +
    #                       pytest.INSTANCENAME + '.conf')
    # assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' +
    #                       pytest.INSTANCENAME + '/green')

    repo_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), '../..'))

    result = pytest.run_cli(isotool, [
        'environment', 'install', '--no-sudo', '--source', 'copy', '--url',
        repo_path, '--skip-provisions', '--skip-frontend'
    ],
                            full_log=True)

    # TODO: Github doesn't like messing with /tmp folders, apparently. These fail
    #  completely on github, yet neither on my local dev install or a docker build.
    # assert result.exit_code == 0
    # assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' +
    #                       pytest.INSTANCENAME + '/green')
    # assert os.path.exists('/tmp/isomer-test/var/cache/isomer/' +
    #                       pytest.INSTANCENAME + '/green')
    # assert os.path.exists('/tmp/isomer-test/var/local/isomer/' +
    #                       pytest.INSTANCENAME + '/green')
    # assert os.path.exists(
    #     '/tmp/isomer-test/var/lib/isomer/' +
    #     pytest.INSTANCENAME + '/green/venv/bin/python3')
    # assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' +
    #                       pytest.INSTANCENAME + '/green/venv/bin/iso')
    # assert os.path.exists('/tmp/isomer-test/var/lib/isomer/' +
    #                       pytest.INSTANCENAME + '/green/repository')
    # assert os.path.exists(
    #     '/tmp/isomer-test/var/lib/isomer/' +
    #     pytest.INSTANCENAME + '/green/repository/frontend')

    instance_configuration = load_instance(pytest.INSTANCENAME)
    environment = instance_configuration['environments']['green']

    assert environment['installed'] is True
    assert environment['provisioned'] is False
    assert environment['migrated'] is True
    assert environment['frontend'] is False
    assert environment['tested'] is False
    assert environment['database'] == pytest.INSTANCENAME + '_green'

    if result.exit_code != 0:
        print(result.output)
        print("For more information on possibly failed subtasks, "
              "consult /tmp/isomer_test_run_cli_logfile")