summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorVlastimil Holer <vlastimil.holer@gmail.com>2013-09-04 16:19:54 +0200
committerVlastimil Holer <vlastimil.holer@gmail.com>2013-09-04 16:19:54 +0200
commit1adc68b643b2f73a2a08ca7d19c3fc8e759f06c2 (patch)
tree2cb86908340b09b962890b3dfdf898f60b3bf82d /tests/unittests
parent77c8798388637fcb2f7dbc057cad81e8fd5fbe58 (diff)
downloadvyos-cloud-init-1adc68b643b2f73a2a08ca7d19c3fc8e759f06c2.tar.gz
vyos-cloud-init-1adc68b643b2f73a2a08ca7d19c3fc8e759f06c2.zip
Fix RE matching context variables. Test cleanups.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index 27725930..66a38e31 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -1,7 +1,8 @@
import os
-from mocker import MockerTestCase
-from cloudinit import util
+
from cloudinit.sources import DataSourceOpenNebula as ds
+from cloudinit import util
+from mocker import MockerTestCase
TEST_VARS = {
'var1': 'single',
@@ -19,7 +20,7 @@ SSH_KEY = 'ssh-rsa AAAAB3NzaC1....sIkJhq8wdX+4I3A4cYbYP ubuntu@server-460-%i'
HOSTNAME = 'foo.example.com'
PUBLIC_IP = '10.0.0.3'
-CMD_IP_OUT = '''
+CMD_IP_OUT = '''\
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
@@ -91,6 +92,7 @@ class TestOpenNebulaDataSource(MockerTestCase):
devs_with_answers = {
"TYPE=iso9660": ["/dev/vdb"],
"LABEL=CDROM": ["/dev/sr0"],
+ "LABEL=CONTEXT": ["/dev/sdb"],
}
def my_devs_with(criteria):
@@ -99,7 +101,7 @@ class TestOpenNebulaDataSource(MockerTestCase):
try:
orig_find_devs_with = util.find_devs_with
util.find_devs_with = my_devs_with
- self.assertEqual(["/dev/sr0", "/dev/vdb"],
+ self.assertEqual(["/dev/sdb", "/dev/sr0", "/dev/vdb"],
ds.find_candidate_devs())
finally:
util.find_devs_with = orig_find_devs_with
@@ -161,7 +163,7 @@ def populate_dir(seed_dir, files):
with open(os.path.join(seed_dir, "context.sh"), "w") as fp:
fp.write("# Context variables generated by OpenNebula\n")
for (name, content) in files.iteritems():
- fp.write('%s="%s"\n' % (name.upper(), content))
+ fp.write("%s='%s'\n" % (name.upper(), content.replace(r"'", r"'\''")))
fp.close()
# vi: ts=4 expandtab