Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/test.py @ 196:13527d70e9e3
An additional unit test with a TOML style configuration file
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 03 May 2019 21:59:51 +0200 |
| parents | 28e6c1413947 |
| children | 0b855758ba08 |
comparison
equal
deleted
inserted
replaced
| 195:28e6c1413947 | 196:13527d70e9e3 |
|---|---|
| 221 url = cfg.getvar_s("db.engines.ro.url") | 221 url = cfg.getvar_s("db.engines.ro.url") |
| 222 self.assertEqual( | 222 self.assertEqual( |
| 223 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), | 223 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), |
| 224 url) | 224 url) |
| 225 | 225 |
| 226 def test02_load_with_toml(self): | |
| 227 cfg = self._load( | |
| 228 os.path.join(TESTDATADIR, "conf20.yml"), | |
| 229 os.path.join(TESTDATADIR, "conf21.yml"), | |
| 230 # .ini replaced with an equivalent .toml | |
| 231 os.path.join(TESTDATADIR, "conf24.toml")) | |
| 232 | |
| 233 self.assertEqual(u("the_database_user_2"), | |
| 234 cfg.getvar_s("db.user.name")) | |
| 235 self.assertEqual(u("the-database-password-2"), | |
| 236 cfg.getvar_s("db.user.pwd")) | |
| 237 | |
| 238 tmpdir = cfg.getvar_s("tmpdir") | |
| 239 self.assertEqual(u(os.getcwd()) + u("/tmp\\4"), tmpdir) | |
| 240 | |
| 241 self.assertEqual(u("3rd-host"), | |
| 242 cfg.getvar_s("db.locinfo.ro.hostname")) | |
| 243 self.assertEqual(u("localhost"), | |
| 244 cfg.getvar_s("db.locinfo.rw.hostname")) | |
| 245 | |
| 246 self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) | |
| 247 | |
| 248 url = cfg.getvar_s("db.engines.ro.url") | |
| 249 self.assertEqual( | |
| 250 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), | |
| 251 url) | |
| 252 | |
| 226 def test03_namespace(self): | 253 def test03_namespace(self): |
| 227 cfg = self._load( | 254 cfg = self._load( |
| 228 os.path.join(TESTDATADIR, "conf20.yml"), | 255 os.path.join(TESTDATADIR, "conf20.yml"), |
| 229 os.path.join(TESTDATADIR, "conf21.yml"), | 256 os.path.join(TESTDATADIR, "conf21.yml"), |
| 230 os.path.join(TESTDATADIR, "conf22.ini")) | 257 os.path.join(TESTDATADIR, "conf22.ini")) |
