summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-05-27 15:07:54 -0400
committerScott Moser <smoser@ubuntu.com>2016-05-27 15:07:54 -0400
commitc0788ee76bf62fa0be570932273ff47212bc9d6c (patch)
treeb9f69218fcc4d551d5e425dc22c468aa9525c59b /tests/unittests/test_datasource
parent7ab03cab899c5bd355c24a4b894c74d63c6dd8b6 (diff)
downloadvyos-cloud-init-c0788ee76bf62fa0be570932273ff47212bc9d6c.tar.gz
vyos-cloud-init-c0788ee76bf62fa0be570932273ff47212bc9d6c.zip
add a unit test for conversion
Diffstat (limited to 'tests/unittests/test_datasource')
-rw-r--r--tests/unittests/test_datasource/test_smartos.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index ae45513d..10e3113e 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -41,7 +41,7 @@ from cloudinit import helpers as c_helpers
from cloudinit.sources import DataSourceSmartOS
from cloudinit.util import b64e
-from ..helpers import mock, FilesystemMockingTestCase
+from ..helpers import mock, FilesystemMockingTestCase, TestCase
SDC_NICS = json.loads("""
[
@@ -517,3 +517,23 @@ class TestJoyentMetadataClient(FilesystemMockingTestCase):
client = self._get_client()
client._checksum = lambda _: self.response_parts['crc']
self.assertIsNone(client.get('some_key'))
+
+
+class TestNetworkConversion(TestCase):
+
+ def test_convert_simple(self):
+ expected = {
+ 'version': 1,
+ 'config': [
+ {'name': 'net0', 'type': 'physical',
+ 'subnets': [{'type': 'static', 'gateway': '8.12.42.1',
+ 'netmask': '255.255.255.0',
+ 'address': '8.12.42.102/24'}],
+ 'mtu': 1500, 'mac_address': '90:b8:d0:f5:e4:f5'},
+ {'name': 'net1', 'type': 'physical',
+ 'subnets': [{'type': 'static', 'gateway': '192.168.128.1',
+ 'netmask': '255.255.252.0',
+ 'address': '192.168.128.93/22'}],
+ 'mtu': 8500, 'mac_address': '90:b8:d0:a5:ff:cd'}]}
+ found = DataSourceSmartOS.convert_smartos_network_data(SDC_NICS)
+ self.assertEqual(expected, found)