def test_override_with_non_string(self): testcfg = "/tmp/invalid_file" result = None with pytest.raises(Exception) as excinfo: result = config.load_config(config_file_override=[testcfg]) assert result is None assert "must be a string" in str(excinfo.value)
def test_read_missing_configuration(self): testcfg = "/tmp/invalid_file" result = None with pytest.raises(Exception) as excinfo: result = config.load_config(config_file_override=testcfg) assert result is None assert "Couldn't find" in str(excinfo.value)
def test_run_novaclient_with_debug(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) supernova_args = { 'debug': True, 'executable': 'echo', 'nova_env': 'dfw' } result = supernova.run_command(nova_creds, ['list'], supernova_args) assert result == 0
def test_run_novaclient_with_debug(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) supernova_args = { 'debug': True, 'executable': 'echo', 'nova_env': 'dfw', 'quiet': False, } result = supernova.run_command(nova_creds, ['list'], supernova_args) assert result == 0
def test_run_novaclient(self): # def mockreturn(commandline): # return False # monkeypatch.setattr(supernova, "execute_executable", mockreturn) testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) supernova_args = { 'debug': False, 'executable': 'echo', 'nova_env': 'dfw' } result = supernova.run_command(nova_creds, ['list'], supernova_args) assert result == 0
def test_dynamic_sections_without_default(self): result = config.load_config() result['dynamic-section'] = {'OS_REGION_NAME': "DFW;ORD"} config.create_dynamic_configs(result) # The new sections exist assert 'dynamic-section-ORD' in result.sections assert 'dynamic-section-DFW' in result.sections # The default section is no longer provided assert 'dynamic-section' not in result.sections # The super group is set up correctly assert 'dynamic-section' in \ result['dynamic-section-ORD'].get('SUPERNOVA_GROUP') assert 'dynamic-section' == \ result['dynamic-section-DFW'].get('SUPERNOVA_GROUP') # The regions are correct assert 'ORD' == \ result['dynamic-section-ORD'].get('OS_REGION_NAME') assert 'DFW' == \ result['dynamic-section-DFW'].get('OS_REGION_NAME')
def test_dynamic_sections_using_tenant(self): result = config.load_config() result['dynamic-section'] = {'OS_TENANT_NAME': "dev;prod"} config.create_dynamic_configs(result) # The new sections exist assert 'dynamic-section-dev' in result.sections assert 'dynamic-section-prod' in result.sections # The default section is no longer provided assert 'dynamic-section' not in result.sections # The super group is set up correctly assert 'dynamic-section' in \ result['dynamic-section-dev'].get('SUPERNOVA_GROUP') assert 'dynamic-section' == \ result['dynamic-section-prod'].get('SUPERNOVA_GROUP') # The regions are correct assert 'dev' == \ result['dynamic-section-dev'].get('OS_TENANT_NAME') assert 'prod' == \ result['dynamic-section-prod'].get('OS_TENANT_NAME')
def test_read_valid_configuration(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) result = config.load_config(config_file_override=testcfg) assert result is not None assert len(result.keys()) == 5 assert 'dfw' in result.keys()
def test_read_valid_configuration(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) result = config.load_config(config_file_override=testcfg) assert result is not None assert len(result.keys()) == 7 assert 'dfw' in result.keys()
def test_get_envs_in_group(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) result = utils.get_envs_in_group('raxusa', nova_creds) assert len(result) == 3 assert 'dfw' in result
def test_is_valid_group_failure(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) result = utils.is_valid_group('non-existent', nova_creds) assert not result
def test_is_valid_group_success(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) result = utils.is_valid_group('raxusa', nova_creds) assert result
def test_is_valid_environment_success(self): testcfg = "{0}/tests/configs/rax_without_keyring".format(os.getcwd()) nova_creds = config.load_config(testcfg) result = utils.is_valid_environment('dfw', nova_creds) assert result