comparison tests/test.py @ 756:cabd1046d95f

Extract new config methods extract_new_config
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Dec 2023 09:20:30 +0100
parents 04c5a3a36499
children 3eb2c451026b
comparison
equal deleted inserted replaced
755:04c5a3a36499 756:cabd1046d95f
2604 TypeError, 2604 TypeError,
2605 self.unquote, 2605 self.unquote,
2606 b":") 2606 b":")
2607 2607
2608 2608
2609 class T11NewConfig(unittest.TestCase):
2610
2611 def setUp(self):
2612 self._cfg = configmix.load(
2613 os.path.join(TESTDATADIR, "extract-new-config.yml"))
2614
2615 def tearDown(self):
2616 self._cfg = None
2617
2618 def test_extract_new_copy(self):
2619 nc = self._cfg.extract_new_config("globals")
2620 self.assertEqual(u(r"E:\APPS64\PostgreSQL-9.4\all\bin"),
2621 nc.getvarl_s(u"PATH"))
2622 self.assertEqual(
2623 u("postgresql+psycopg2://My%20Username:My%20Password@localhost:5432/postgres"),
2624 nc.getvarl_s("engine0", "url"))
2625 self.assertIsInstance(self._cfg.getvarl("parts"), list)
2626 with self.assertRaises(KeyError):
2627 nc.getvarl("parts")
2628
2629 def test_extract_new_copy_is_deepcopy(self):
2630 nc = self._cfg.extract_new_config("globals")
2631 user2 = nc.getvarl(u("user2"))
2632 user2[u("pwd")] = u("new passphrase")
2633 self.assertEqual(u("new passphrase"),
2634 nc.getvarl(u("user2"), u("pwd")))
2635 self.assertEqual(u("abcQQQ123456"),
2636 self._cfg.getvarl(u("globals"), u("user2"), u("pwd")))
2637
2638
2609 if __name__ == "__main__": 2639 if __name__ == "__main__":
2610 unittest.main() 2640 unittest.main()