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_bad_config_arg(self): result = None with pytest.raises(ValueError) as val_error: result = config.create_dynamic_configs('bad_arg') assert result is None assert "config should be ConfigObj" in str(val_error)