diff options
author | Ben Howard <ben.howard@canonical.com> | 2014-02-07 13:49:03 +0200 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2014-02-07 13:49:03 +0200 |
commit | ceffb35a2ddfb5f309417aaa68e7ff70199690fa (patch) | |
tree | a0810797bd45c06ce913d788b507021e747e0a49 /tests/unittests/test_datasource/test_azure.py | |
parent | 3087da32ec5cf84c51e0ebdd80a71a84b174a392 (diff) | |
download | vyos-cloud-init-ceffb35a2ddfb5f309417aaa68e7ff70199690fa.tar.gz vyos-cloud-init-ceffb35a2ddfb5f309417aaa68e7ff70199690fa.zip |
Made new ovf-env.xml handling more robust. Test cases included
Diffstat (limited to 'tests/unittests/test_datasource/test_azure.py')
-rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index aad84206..aa541a18 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -119,6 +119,10 @@ class TestAzureDataSource(MockerTestCase): {'ovf-env.xml': data['ovfcontent']}) mod = DataSourceAzure + ddir = "%s/var/lib/waagent" % self.tmp + mod.BUILTIN_DS_CONFIG['data_dir'] = ddir + if not os.path.isdir(ddir): + os.makedirs(ddir) self.apply_patches([(mod, 'list_possible_azure_ds_devs', dsdevs)]) @@ -338,6 +342,40 @@ class TestAzureDataSource(MockerTestCase): self.assertEqual(userdata, dsrc.userdata_raw) + def test_existing_ovf_same(self): + mydata = "FOOBAR" + odata = {'UserData': base64.b64encode(mydata)} + data = {'ovfcontent': construct_valid_ovf_env(data=odata)} + + with open("%s/ovf-env.xml" % self.tmp, 'w') as fp: + fp.write(construct_valid_ovf_env(data=odata)) + with open("%s/sem" % self.tmp, 'w') as fp: + fp.write("test") + + dsrc = self._get_ds(data) + ret = dsrc.get_data() + self.assertTrue(ret) + self.assertEqual(dsrc.userdata_raw, mydata) + self.assertTrue(os.path.exists("%s/sem" % self.tmp)) + + def test_existing_ovf_diff(self): + mydata = "FOOBAR" + odata = {'UserData': base64.b64encode(mydata)} + data = {'ovfcontent': construct_valid_ovf_env(data=odata)} + + data_dir = "%s/var/lib/waagent" % self.tmp + os.makedirs(data_dir) + with open("%s/ovf-env.xml" % data_dir, 'w') as fp: + fp.write(construct_valid_ovf_env()) + with open("%s/sem" % data_dir, 'w') as fp: + fp.write("test") + + dsrc = self._get_ds(data) + ret = dsrc.get_data() + self.assertTrue(ret) + self.assertEqual(dsrc.userdata_raw, mydata) + self.assertFalse(os.path.exists("%s/sem" % data_dir)) + class TestReadAzureOvf(MockerTestCase): def test_invalid_xml_raises_non_azure_ds(self): |