summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_common.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-12-07 19:17:03 +0100
committerScott Moser <smoser@ubuntu.com>2016-12-11 20:56:23 -0500
commita9d41de47a58d967ae3fd6a7749f8143a14424d3 (patch)
tree49a0922dfe7ee7d8224e5e10bd5171008c8cf9f8 /tests/unittests/test_datasource/test_common.py
parentcbf93eb4ae9fba0797ab4ae7d62bc0d64611fa7e (diff)
downloadvyos-cloud-init-a9d41de47a58d967ae3fd6a7749f8143a14424d3.tar.gz
vyos-cloud-init-a9d41de47a58d967ae3fd6a7749f8143a14424d3.zip
CloudSigma: Fix bug where datasource was not loaded in local search.
CloudSigma would not get any datasources loaded during cloud-init local. Thus, when the network datasource was removed, *no* CloudSigma datasources would be loaded. LP: #1648380
Diffstat (limited to 'tests/unittests/test_datasource/test_common.py')
-rw-r--r--tests/unittests/test_datasource/test_common.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_common.py b/tests/unittests/test_datasource/test_common.py
new file mode 100644
index 00000000..d1d3f2af
--- /dev/null
+++ b/tests/unittests/test_datasource/test_common.py
@@ -0,0 +1,73 @@
+from cloudinit import settings
+from cloudinit import sources
+from cloudinit import type_utils
+from cloudinit.sources import (
+ DataSourceAliYun as AliYun,
+ DataSourceAltCloud as AltCloud,
+ DataSourceAzure as Azure,
+ DataSourceBigstep as Bigstep,
+ DataSourceCloudSigma as CloudSigma,
+ DataSourceCloudStack as CloudStack,
+ DataSourceConfigDrive as ConfigDrive,
+ DataSourceDigitalOcean as DigitalOcean,
+ DataSourceEc2 as Ec2,
+ DataSourceGCE as GCE,
+ DataSourceMAAS as MAAS,
+ DataSourceNoCloud as NoCloud,
+ DataSourceOpenNebula as OpenNebula,
+ DataSourceOpenStack as OpenStack,
+ DataSourceOVF as OVF,
+ DataSourceSmartOS as SmartOS,
+)
+from cloudinit.sources import DataSourceNone as DSNone
+
+from .. import helpers as test_helpers
+
+DEFAULT_LOCAL = [
+ CloudSigma.DataSourceCloudSigma,
+ ConfigDrive.DataSourceConfigDrive,
+ DigitalOcean.DataSourceDigitalOcean,
+ NoCloud.DataSourceNoCloud,
+ OpenNebula.DataSourceOpenNebula,
+ OVF.DataSourceOVF,
+ SmartOS.DataSourceSmartOS,
+]
+
+DEFAULT_NETWORK = [
+ AltCloud.DataSourceAltCloud,
+ Azure.DataSourceAzureNet,
+ Bigstep.DataSourceBigstep,
+ CloudStack.DataSourceCloudStack,
+ DSNone.DataSourceNone,
+ Ec2.DataSourceEc2,
+ GCE.DataSourceGCE,
+ MAAS.DataSourceMAAS,
+ NoCloud.DataSourceNoCloudNet,
+ OpenStack.DataSourceOpenStack,
+ OVF.DataSourceOVFNet,
+]
+
+
+class ExpectedDataSources(test_helpers.TestCase):
+ builtin_list = settings.CFG_BUILTIN['datasource_list']
+ deps_local = [sources.DEP_FILESYSTEM]
+ deps_network = [sources.DEP_FILESYSTEM, sources.DEP_NETWORK]
+ pkg_list = [type_utils.obj_name(sources)]
+
+ def test_expected_default_local_sources_found(self):
+ found = sources.list_sources(
+ self.builtin_list, self.deps_local, self.pkg_list)
+ self.assertEqual(set(DEFAULT_LOCAL), set(found))
+
+ def test_expected_default_network_sources_found(self):
+ found = sources.list_sources(
+ self.builtin_list, self.deps_network, self.pkg_list)
+ self.assertEqual(set(DEFAULT_NETWORK), set(found))
+
+ def test_expected_nondefault_network_sources_found(self):
+ found = sources.list_sources(
+ ['AliYun'], self.deps_network, self.pkg_list)
+ self.assertEqual(set([AliYun.DataSourceAliYun]), set(found))
+
+
+# vi: ts=4 expandtab