summaryrefslogtreecommitdiff
path: root/tests/unittests/sources/test___init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/sources/test___init__.py')
-rw-r--r--tests/unittests/sources/test___init__.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unittests/sources/test___init__.py b/tests/unittests/sources/test___init__.py
new file mode 100644
index 00000000..b84976da
--- /dev/null
+++ b/tests/unittests/sources/test___init__.py
@@ -0,0 +1,40 @@
+import pytest
+
+from cloudinit import sources
+from cloudinit.sources import DataSourceOpenStack as ds
+from tests.unittests.helpers import mock
+
+
+@pytest.mark.parametrize(
+ "m_cmdline",
+ (
+ # test ci.ds=
+ "aosiejfoij ci.ds=OpenStack ",
+ "ci.ds=OpenStack",
+ "aosiejfoij ci.ds=OpenStack blah",
+ "aosiejfoij ci.ds=OpenStack faljskebflk",
+ # test ci.datasource=
+ "aosiejfoij ci.datasource=OpenStack ",
+ "ci.datasource=OpenStack",
+ "aosiejfoij ci.datasource=OpenStack blah",
+ "aosiejfoij ci.datasource=OpenStack faljskebflk",
+ # weird whitespace
+ "ci.datasource=OpenStack\n",
+ "ci.datasource=OpenStack\t",
+ "ci.datasource=OpenStack\r",
+ "ci.datasource=OpenStack\v",
+ "ci.ds=OpenStack\n",
+ "ci.ds=OpenStack\t",
+ "ci.ds=OpenStack\r",
+ "ci.ds=OpenStack\v",
+ ),
+)
+def test_ds_detect_kernel_commandline(m_cmdline):
+ """check commandline match"""
+ with mock.patch(
+ "cloudinit.util.get_cmdline",
+ return_value=m_cmdline,
+ ):
+ assert (
+ ds.DataSourceOpenStack.dsname == sources.parse_cmdline()
+ ), f"could not parse [{m_cmdline}]"