summaryrefslogtreecommitdiff
path: root/taskflow/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-05-01 12:44:17 -0700
committerJoshua Harlow <harlowja@gmail.com>2015-05-02 10:31:40 -0700
commit7c3fdcc8c4bdfd156cca83e9f840aed0c8eb37ad (patch)
treee6c12d3acfd2ebd805cbefa2f5ec87dcaee74d17 /taskflow/tests/unit/test_utils.py
parent1fc59837ebddacc530536008ec4fd71e7dc3ec88 (diff)
downloadtaskflow-7c3fdcc8c4bdfd156cca83e9f840aed0c8eb37ad.tar.gz
Small refactoring of 'merge_uri' utility function
Perform some small adjustments/cleanups and add some unit tests to ensure this function keeps operating as expected. Change-Id: I496bd6844072f57624de31fc7ddb0362f163cc53
Diffstat (limited to 'taskflow/tests/unit/test_utils.py')
-rw-r--r--taskflow/tests/unit/test_utils.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/taskflow/tests/unit/test_utils.py b/taskflow/tests/unit/test_utils.py
index 2465f9f..c136cb7 100644
--- a/taskflow/tests/unit/test_utils.py
+++ b/taskflow/tests/unit/test_utils.py
@@ -262,6 +262,42 @@ class TestLookFor(test.TestCase):
self.assertEqual([10, 44], misc.look_for(hay, [44, 10]))
+class TestMergeUri(test.TestCase):
+ def test_merge(self):
+ url = "http://www.yahoo.com/?a=b&c=d"
+ parsed = misc.parse_uri(url)
+ joined = misc.merge_uri(parsed, {})
+ self.assertEqual('b', joined.get('a'))
+ self.assertEqual('d', joined.get('c'))
+ self.assertEqual('www.yahoo.com', joined.get('hostname'))
+
+ def test_merge_existing_hostname(self):
+ url = "http://www.yahoo.com/"
+ parsed = misc.parse_uri(url)
+ joined = misc.merge_uri(parsed, {'hostname': 'b.com'})
+ self.assertEqual('b.com', joined.get('hostname'))
+
+ def test_merge_user_password(self):
+ url = "http://josh:harlow@www.yahoo.com/"
+ parsed = misc.parse_uri(url)
+ joined = misc.merge_uri(parsed, {})
+ self.assertEqual('www.yahoo.com', joined.get('hostname'))
+ self.assertEqual('josh', joined.get('username'))
+ self.assertEqual('harlow', joined.get('password'))
+
+ def test_merge_user_password_existing(self):
+ url = "http://josh:harlow@www.yahoo.com/"
+ parsed = misc.parse_uri(url)
+ existing = {
+ 'username': 'joe',
+ 'password': 'biggie',
+ }
+ joined = misc.merge_uri(parsed, existing)
+ self.assertEqual('www.yahoo.com', joined.get('hostname'))
+ self.assertEqual('joe', joined.get('username'))
+ self.assertEqual('biggie', joined.get('password'))
+
+
class TestClamping(test.TestCase):
def test_simple_clamp(self):
result = misc.clamp(1.0, 2.0, 3.0)