/tests/unit/test_tmplconfig.py
Python | 29 lines | 26 code | 3 blank | 0 comment | 0 complexity | 7696db1517c3c12f77d5fba5c80095f8 MD5 | raw file
Possible License(s): GPL-2.0
1import os 2from silverlining import tmplconfig 3 4here = os.path.dirname(os.path.abspath(__file__)) 5 6 7def test_config(): 8 conf = tmplconfig.Configuration( 9 os.path.join(here, 'test_tmplconfig.ini')) 10 assert conf.general.name == 'my-server-setup' 11 assert tmplconfig.asbool(conf.general.set_etc_hosts) is False 12 assert getattr(conf.general, 'foobar', None) is None 13 os.environ['FAKE_HOME'] = '/my-home' 14 assert conf.provider['secret_file'] == '{{environ.FAKE_HOME}}/.rackspace-secret.txt' 15 assert conf.provider.secret_file == '/my-home/.rackspace-secret.txt' 16 assert tmplconfig.lines(conf.appserver.locations) == ['http://foobar.com/ APP_NAME1'] 17 sec = conf.sections('service:')['mysql'] 18 assert int(sec.nodes) == 1 19 s = unicode(conf.balancer) 20 s = s.replace(here, 'HERE') 21 assert s == u"""\ 22# Without special support, generally just 1 node is supported 23# also node_name/size 24[balancer] 25# From HERE/test_tmplconfig.ini: 26# Describes the load balancer 27node_name = balancer.foobar.com 28hostnames = foobar.com 29 baz.com""", s