diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-02-24 11:58:22 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-02-24 11:58:22 -0500 |
commit | f1ee9275a504c20153b795923b1f51d3005d745c (patch) | |
tree | 626ec9f03f7bfab4c8107a46ab0680420eb6b8e9 /tests/unittests/test_udprocess.py | |
parent | 43a8d82141c5abcdf5ca546fd5a8ebc95cb3cbaf (diff) | |
download | vyos-cloud-init-f1ee9275a504c20153b795923b1f51d3005d745c.tar.gz vyos-cloud-init-f1ee9275a504c20153b795923b1f51d3005d745c.zip |
use util.decode_binary rather than str, add tests.
just seems to make more sense to decode here.
Add a test showing the previous failure (testBytesInPayload)
And one that should pass (testStringInPayload)
Also, add a test for unencoded content in the ovf xml (test_userdata_plain)
And explicitly set encoding on another test (test_userdata_found).
Diffstat (limited to 'tests/unittests/test_udprocess.py')
-rw-r--r-- | tests/unittests/test_udprocess.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unittests/test_udprocess.py b/tests/unittests/test_udprocess.py new file mode 100644 index 00000000..39adbf9d --- /dev/null +++ b/tests/unittests/test_udprocess.py @@ -0,0 +1,30 @@ +from . import helpers + +from six.moves import filterfalse + +from cloudinit import user_data as ud +from cloudinit import util + +def count_messages(root): + am = 0 + for m in root.walk(): + if ud.is_skippable(m): + continue + am += 1 + return am + + +class TestUDProcess(helpers.ResourceUsingTestCase): + + def testBytesInPayload(self): + msg = b'#cloud-config\napt_update: True\n' + ud_proc = ud.UserDataProcessor(self.getCloudPaths()) + message = ud_proc.process(msg) + self.assertTrue(count_messages(message) == 1) + + def testStringInPayload(self): + msg = '#cloud-config\napt_update: True\n' + + ud_proc = ud.UserDataProcessor(self.getCloudPaths()) + message = ud_proc.process(msg) + self.assertTrue(count_messages(message) == 1) |