summaryrefslogtreecommitdiff
path: root/tests/unittests/test_udprocess.py
blob: 39adbf9d21188286285f10d42a82ffde836bfbbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)