summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-03-04 14:35:09 -0500
committerScott Moser <smoser@ubuntu.com>2014-03-04 14:35:09 -0500
commita9c7562ff3be9c552d757f24cfa61ef8985fe2e2 (patch)
treeecdcf5232c9b5d2d0d0145cf1ce5ea3d7170d567 /tests/unittests
parentd7b79b1c5703a9fc4d533d15efa5fdb1f4f8352b (diff)
parent5c95d6817a4aea17054addceef5d955c75390aa1 (diff)
downloadvyos-cloud-init-a9c7562ff3be9c552d757f24cfa61ef8985fe2e2.tar.gz
vyos-cloud-init-a9c7562ff3be9c552d757f24cfa61ef8985fe2e2.zip
merge from trunk
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_datasource/test_cloudsigma.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_cloudsigma.py b/tests/unittests/test_datasource/test_cloudsigma.py
index 3245aba1..adbb4afb 100644
--- a/tests/unittests/test_datasource/test_cloudsigma.py
+++ b/tests/unittests/test_datasource/test_cloudsigma.py
@@ -1,4 +1,5 @@
# coding: utf-8
+import copy
from unittest import TestCase
from cloudinit.cs_utils import Cepko
@@ -24,7 +25,8 @@ SERVER_CONTEXT = {
class CepkoMock(Cepko):
- result = SERVER_CONTEXT
+ def __init__(self, mocked_context):
+ self.result = mocked_context
def all(self):
return self
@@ -33,7 +35,7 @@ class CepkoMock(Cepko):
class DataSourceCloudSigmaTest(TestCase):
def setUp(self):
self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
- self.datasource.cepko = CepkoMock()
+ self.datasource.cepko = CepkoMock(SERVER_CONTEXT)
self.datasource.get_data()
def test_get_hostname(self):
@@ -57,3 +59,12 @@ class DataSourceCloudSigmaTest(TestCase):
def test_user_data(self):
self.assertEqual(self.datasource.userdata_raw,
SERVER_CONTEXT['meta']['cloudinit-user-data'])
+
+ def test_encoded_user_data(self):
+ encoded_context = copy.deepcopy(SERVER_CONTEXT)
+ encoded_context['meta']['base64_fields'] = 'cloudinit-user-data'
+ encoded_context['meta']['cloudinit-user-data'] = 'aGkgd29ybGQK'
+ self.datasource.cepko = CepkoMock(encoded_context)
+ self.datasource.get_data()
+
+ self.assertEqual(self.datasource.userdata_raw, b'hi world\n')