Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: server/base_utils_unittest.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: server/base_utils_unittest.py
diff --git a/server/base_utils_unittest.py b/server/base_utils_unittest.py
index 111dfbe29ee5948d4eb223ee1d342f3f2848c8e9..feb9aceb416d446a469cef66d33480fe87edfd1d 100755
--- a/server/base_utils_unittest.py
+++ b/server/base_utils_unittest.py
@@ -26,5 +26,37 @@ class UtilsTest(unittest.TestCase):
self.assertEquals(self.failures, failures)
+ # parse_machine() test cases
+ def test_parse_machine_good(self):
+ '''test that parse_machine() is outputting the correct data'''
+ gooddata = (('host', ('host', 'root', '', 22)),
+ ('host:21', ('host', 'root', '', 21)),
+ ('user@host', ('host', 'user', '', 22)),
+ ('user:pass@host', ('host', 'user', 'pass', 22)),
+ ('user:pass@host:1234', ('host', 'user', 'pass', 1234)),
+ )
+ for machine, result in gooddata:
+ self.assertEquals(utils.parse_machine(machine), result)
+
+
+ def test_parse_machine_override(self):
+ '''Test that parse_machine() defaults can be overridden'''
+ self.assertEquals(utils.parse_machine('host', 'bob', 'foo', 1234),
+ ('host', 'bob', 'foo', 1234))
+
+
+ def test_parse_machine_bad(self):
+ '''test that bad data passed to parse_machine() will raise an exception'''
+ baddata = (('host:port', ValueError), # pass a non-integer string for port
+ ('host:22:33', ValueError), # pass two ports
+ (':22', ValueError), # neglect to pass a hostname #1
+ ('user@', ValueError), # neglect to pass a hostname #2
+ ('user@:22', ValueError), # neglect to pass a hostname #3
+ (':pass@host', ValueError), # neglect to pass a username
+ )
+ for machine, exception in baddata:
+ self.assertRaises(exception, utils.parse_machine, machine)
+
+
if __name__ == "__main__":
unittest.main()
« cli/job.py ('K') | « server/base_utils.py ('k') | server/control_segments/cleanup » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698