/tests/unit/test_tmplconfig.py

https://bitbucket.org/ianb/silverlining/ · Python · 29 lines · 26 code · 3 blank · 0 comment · 0 complexity · 7696db1517c3c12f77d5fba5c80095f8 MD5 · raw file

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