diff options
author | Eugene Kirpichov <ekirpichov@gmail.com> | 2012-09-26 18:23:40 +0000 |
---|---|---|
committer | Eugene Kirpichov <ekirpichov@gmail.com> | 2012-09-26 18:25:59 +0000 |
commit | 8a0c03c9e57926f4bc6c1a0ad9a87b9d59953e6e (patch) | |
tree | 248af9e99c2da85a2593ba360e090b036fa8feee /tests | |
parent | ac5067fb957556fbb2359e0bb8b99b6f733c6a04 (diff) | |
download | oslo-8a0c03c9e57926f4bc6c1a0ad9a87b9d59953e6e.tar.gz oslo-8a0c03c9e57926f4bc6c1a0ad9a87b9d59953e6e.tar.xz oslo-8a0c03c9e57926f4bc6c1a0ad9a87b9d59953e6e.zip |
Extracted parse_host_port into network_utils.
Change-Id: I77bcbf03a18659cfa62e99da9ba2136f8348022b
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_network_utils.py | 42 | ||||
-rw-r--r-- | tests/unit/test_utils.py | 17 |
2 files changed, 42 insertions, 17 deletions
diff --git a/tests/unit/test_network_utils.py b/tests/unit/test_network_utils.py new file mode 100644 index 0000000..2641d2d --- /dev/null +++ b/tests/unit/test_network_utils.py @@ -0,0 +1,42 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import unittest + +import mock + +from openstack.common import network_utils as utils + + +class NetworkUtilsTest(unittest.TestCase): + + def test_parse_host_port(self): + self.assertEqual(('server01', 80), + utils.parse_host_port('server01:80')) + self.assertEqual(('server01', None), + utils.parse_host_port('server01')) + self.assertEqual(('server01', 1234), + utils.parse_host_port('server01', default_port=1234)) + self.assertEqual(('::1', 80), + utils.parse_host_port('[::1]:80')) + self.assertEqual(('::1', None), + utils.parse_host_port('[::1]')) + self.assertEqual(('::1', 1234), + utils.parse_host_port('[::1]', default_port=1234)) + self.assertEqual(('2001:db8:85a3::8a2e:370:7334', 1234), + utils.parse_host_port('2001:db8:85a3::8a2e:370:7334', + default_port=1234)) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 7dadf72..135f49d 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -80,20 +80,3 @@ class UtilsTest(unittest.TestCase): # running code. def test_execute_unknown_kwargs(self): self.assertRaises(exception.Error, utils.execute, hozer=True) - - def test_parse_host_port(self): - self.assertEqual(('server01', 80), - utils.parse_host_port('server01:80')) - self.assertEqual(('server01', None), - utils.parse_host_port('server01')) - self.assertEqual(('server01', 1234), - utils.parse_host_port('server01', default_port=1234)) - self.assertEqual(('::1', 80), - utils.parse_host_port('[::1]:80')) - self.assertEqual(('::1', None), - utils.parse_host_port('[::1]')) - self.assertEqual(('::1', 1234), - utils.parse_host_port('[::1]', default_port=1234)) - self.assertEqual(('2001:db8:85a3::8a2e:370:7334', 1234), - utils.parse_host_port('2001:db8:85a3::8a2e:370:7334', - default_port=1234)) |