From ec6d4e10304293157ba61501b7f053cb1cbc142a Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 13 Aug 2013 09:53:32 +0000 Subject: deploy: refactor environment argument parsing It is now a tested helper function in morphlib.util --- morphlib/util_tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'morphlib/util_tests.py') diff --git a/morphlib/util_tests.py b/morphlib/util_tests.py index eaff0821..ca9fe5ae 100644 --- a/morphlib/util_tests.py +++ b/morphlib/util_tests.py @@ -87,3 +87,21 @@ class FindParentOfTests(unittest.TestCase): def test_find_leaf_returns_none_if_not_found(self): self.assertEqual(morphlib.util.find_leaf(self.a, '.magic'), None) + +class ParseEnvironmentPairsTests(unittest.TestCase): + + def test_parse_environment_pairs_adds_key(self): + ret = morphlib.util.parse_environment_pairs({}, ["foo=bar"]) + self.assertEqual(ret.get("foo"), "bar") + + def test_parse_environment_does_not_alter_passed_dict(self): + d = {} + morphlib.util.parse_environment_pairs(d, ["foo=bar"]) + self.assertTrue("foo" not in d) + + def test_parse_environment_raises_on_duplicates(self): + self.assertRaises( + morphlib.util.EnvironmentAlreadySetError, + morphlib.util.parse_environment_pairs, + {"foo": "bar"}, + ["foo=bar"]) -- cgit v1.2.1