summaryrefslogtreecommitdiff
path: root/tests/unittests/sources/test_bigstep.py
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2022-07-01 10:07:15 -0500
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2022-07-01 16:34:09 +0000
commitcff8a8b47acf7048ad08bd121e677fb86e73635b (patch)
tree011f38ddb27b3df74d78115ebe59be951558edea /tests/unittests/sources/test_bigstep.py
parent15d691e3b0b32c67b0589665b49e9d2755296d1b (diff)
downloadcloud-init-git-cff8a8b47acf7048ad08bd121e677fb86e73635b.tar.gz
22.2-64-g1fcd55d6-0ubuntu1~22.10.1 (patches unapplied)
Imported using git-ubuntu import.
Diffstat (limited to 'tests/unittests/sources/test_bigstep.py')
-rw-r--r--tests/unittests/sources/test_bigstep.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unittests/sources/test_bigstep.py b/tests/unittests/sources/test_bigstep.py
new file mode 100644
index 00000000..148cfa0b
--- /dev/null
+++ b/tests/unittests/sources/test_bigstep.py
@@ -0,0 +1,46 @@
+import json
+import os
+
+import httpretty
+import pytest
+
+from cloudinit import helpers
+from cloudinit.sources import DataSourceBigstep as bigstep
+from tests.unittests.helpers import mock
+
+M_PATH = "cloudinit.sources.DataSourceBigstep."
+
+IMDS_URL = "http://bigstep.com"
+METADATA_BODY = json.dumps(
+ {
+ "metadata": "metadata",
+ "vendordata_raw": "vendordata_raw",
+ "userdata_raw": "userdata_raw",
+ }
+)
+
+
+class TestBigstep:
+ @httpretty.activate
+ @pytest.mark.parametrize("custom_paths", [False, True])
+ @mock.patch(M_PATH + "util.load_file", return_value=IMDS_URL)
+ def test_get_data_honor_cloud_dir(self, m_load_file, custom_paths, tmpdir):
+ httpretty.register_uri(httpretty.GET, IMDS_URL, body=METADATA_BODY)
+
+ paths = {}
+ url_file = "/var/lib/cloud/data/seed/bigstep/url"
+ if custom_paths:
+ paths = {
+ "cloud_dir": tmpdir.join("cloud"),
+ "run_dir": tmpdir,
+ "templates_dir": tmpdir,
+ }
+ url_file = os.path.join(
+ paths["cloud_dir"], "data", "seed", "bigstep", "url"
+ )
+
+ ds = bigstep.DataSourceBigstep(
+ sys_cfg={}, distro=mock.Mock(), paths=helpers.Paths(paths)
+ )
+ assert ds._get_data()
+ assert [mock.call(url_file)] == m_load_file.call_args_list