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
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'])
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
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
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
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')
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
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")