summaryrefslogtreecommitdiff
path: root/tests/unittests/sources/test_ec2.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/sources/test_ec2.py')
-rw-r--r--tests/unittests/sources/test_ec2.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/unittests/sources/test_ec2.py b/tests/unittests/sources/test_ec2.py
index 4c832da7..3fe525e3 100644
--- a/tests/unittests/sources/test_ec2.py
+++ b/tests/unittests/sources/test_ec2.py
@@ -5,6 +5,7 @@ import json
import threading
from unittest import mock
+import pytest
import requests
import responses
@@ -223,6 +224,12 @@ TAGS_METADATA_2021_03_23: dict = {
}
+@pytest.fixture(autouse=True)
+def disable_is_resolvable():
+ with mock.patch("cloudinit.sources.DataSourceEc2.util.is_resolvable"):
+ yield
+
+
def _register_ssh_keys(rfunc, base_url, keys_data):
"""handle ssh key inconsistencies.
@@ -303,7 +310,7 @@ def register_mock_metaserver(base_url, data, responses_mock=None):
def myreg(*argc, **kwargs):
url, body = argc
- method = responses.PUT if ec2.API_TOKEN_ROUTE in url else responses.GET
+ method = responses.PUT if "latest/api/token" in url else responses.GET
status = kwargs.get("status", 200)
return responses_mock.add(method, url, body, status=status)
@@ -1180,6 +1187,16 @@ class TesIdentifyPlatform(test_helpers.CiTestCase):
return unspecial
@mock.patch("cloudinit.sources.DataSourceEc2._collect_platform_data")
+ def test_identify_aliyun(self, m_collect):
+ """aliyun should be identified if product name equals to
+ Alibaba Cloud ECS
+ """
+ m_collect.return_value = self.collmock(
+ product_name="Alibaba Cloud ECS"
+ )
+ self.assertEqual(ec2.CloudNames.ALIYUN, ec2.identify_platform())
+
+ @mock.patch("cloudinit.sources.DataSourceEc2._collect_platform_data")
def test_identify_zstack(self, m_collect):
"""zstack should be identified if chassis-asset-tag
ends in .zstack.io