tests: Switch the azure examples used in the lifted tests to use aws

This commit is contained in:
Brian C. Lane 2019-10-11 14:38:06 -07:00
parent 6f0473c742
commit 0eb01b84a8
2 changed files with 44 additions and 44 deletions

View File

@ -42,15 +42,15 @@ class ProvidersTestCase(unittest.TestCase):
def test_get_profile_path(self):
"""Make sure that _get_profile_path strips path elements from the input"""
path = _get_profile_path(self.config["upload"], "azure", "staging-settings", exists=False)
self.assertEqual(path, os.path.abspath(joinpaths(self.config["upload"]["settings_dir"], "azure/staging-settings.toml")))
path = _get_profile_path(self.config["upload"], "aws", "staging-settings", exists=False)
self.assertEqual(path, os.path.abspath(joinpaths(self.config["upload"]["settings_dir"], "aws/staging-settings.toml")))
path = _get_profile_path(self.config["upload"], "../../../../foo/bar/azure", "/not/my/path/staging-settings", exists=False)
self.assertEqual(path, os.path.abspath(joinpaths(self.config["upload"]["settings_dir"], "azure/staging-settings.toml")))
path = _get_profile_path(self.config["upload"], "../../../../foo/bar/aws", "/not/my/path/staging-settings", exists=False)
self.assertEqual(path, os.path.abspath(joinpaths(self.config["upload"]["settings_dir"], "aws/staging-settings.toml")))
def test_list_providers(self):
p = list_providers(self.config["upload"])
self.assertEqual(p, ['aws', 'azure', 'dummy', 'openstack', 'vsphere'])
self.assertEqual(p, ['aws', 'dummy', 'openstack', 'vsphere'])
def test_resolve_provider(self):
for p in list_providers(self.config["upload"]):
@ -79,10 +79,10 @@ class ProvidersTestCase(unittest.TestCase):
validate_settings(self.config["upload"], "dummy", test_profiles["dummy"][1], image_name="")
with self.assertRaises(ValueError):
validate_settings(self.config["upload"], "azure", {"wrong-key": "wrong value"})
validate_settings(self.config["upload"], "aws", {"wrong-key": "wrong value"})
with self.assertRaises(ValueError):
validate_settings(self.config["upload"], "azure", {"secret": False})
validate_settings(self.config["upload"], "aws", {"secret": False})
# TODO - test regex, needs a provider with a regex
@ -113,13 +113,13 @@ class ProvidersTestCase(unittest.TestCase):
load_settings(self.config["upload"], "", "default")
with self.assertRaises(ValueError):
load_settings(self.config["upload"], "azure", "")
load_settings(self.config["upload"], "aws", "")
with self.assertRaises(RuntimeError):
load_settings(self.config["upload"], "foo", "default")
with self.assertRaises(RuntimeError):
load_settings(self.config["upload"], "azure", "missing-test")
load_settings(self.config["upload"], "aws", "missing-test")
# This *must* run after test_save_settings, _zz_ ensures that happens
def test_zz_load_settings(self):
@ -139,19 +139,19 @@ class ProvidersTestCase(unittest.TestCase):
delete_profile(self.config["upload"], "", "default")
with self.assertRaises(ValueError):
delete_profile(self.config["upload"], "azure", "")
delete_profile(self.config["upload"], "aws", "")
with self.assertRaises(RuntimeError):
delete_profile(self.config["upload"], "azure", "missing-test")
delete_profile(self.config["upload"], "aws", "missing-test")
# This *must* run after all the save and load tests, _zzz_ ensures this happens
def test_zzz_delete_settings(self):
"""Test raising the correct errors when deleting"""
# Ensure the profile is really there
settings = load_settings(self.config["upload"], "azure", test_profiles["azure"][0])
self.assertEqual(settings, test_profiles["azure"][1])
settings = load_settings(self.config["upload"], "aws", test_profiles["aws"][0])
self.assertEqual(settings, test_profiles["aws"][1])
delete_profile(self.config["upload"], "azure", test_profiles["azure"][0])
delete_profile(self.config["upload"], "aws", test_profiles["aws"][0])
with self.assertRaises(RuntimeError):
load_settings(self.config["upload"], "azure", test_profiles["azure"][0])
load_settings(self.config["upload"], "aws", test_profiles["aws"][0])

View File

@ -3496,15 +3496,15 @@ class ServerAPIV1TestCase(unittest.TestCase):
self.assertNotEqual(data, None)
self.assertTrue("providers" in data)
providers = sorted(data["providers"].keys())
self.assertEqual(providers, ["aws", "azure", "dummy", "openstack", "vsphere"])
self.assertEqual(providers, ["aws", "dummy", "openstack", "vsphere"])
def test_upload_01_providers_save(self):
"""Save settings for a provider"""
# list of providers, and their settings
test_settings = {
"provider": "azure",
"profile": test_profiles["azure"][0],
"settings": test_profiles["azure"][1]
"provider": "aws",
"profile": test_profiles["aws"][0],
"settings": test_profiles["aws"][1]
}
resp = self.server.post("/api/v1/upload/providers/save",
@ -3518,19 +3518,19 @@ class ServerAPIV1TestCase(unittest.TestCase):
data = json.loads(resp.data)
self.assertNotEqual(data, None)
self.assertTrue("providers" in data)
self.assertTrue("azure" in data["providers"])
self.assertTrue(test_profiles["azure"][0] in data["providers"]["azure"]["profiles"])
self.assertTrue("aws" in data["providers"])
self.assertTrue(test_profiles["aws"][0] in data["providers"]["aws"]["profiles"])
def test_upload_02_compose_profile(self):
"""Test starting a compose with upload profile"""
test_compose = {
"blueprint_name": "example-custom-base",
"compose_type": "vhd",
"compose_type": "ami",
"branch": "master",
"upload": {
"image_name": "Azure custom-base",
"provider": "azure",
"settings": test_profiles["azure"][1]
"image_name": "AWS custom-base",
"provider": "aws",
"settings": test_profiles["aws"][1]
}
}
resp = self.server.post("/api/v1/compose?test=2",
@ -3553,9 +3553,9 @@ class ServerAPIV1TestCase(unittest.TestCase):
print(data)
self.assertEqual(data["status"], True)
self.assertTrue("upload" in data)
self.assertEqual(data["upload"]["provider_name"], "azure")
self.assertEqual(data["upload"]["provider_name"], "aws")
self.assertEqual(data["upload"]["uuid"], upload_id)
self.assertEqual(data["upload"]["image_name"], "Azure custom-base")
self.assertEqual(data["upload"]["image_name"], "AWS custom-base")
# Get the upload log
resp = self.server.get("/api/v1/upload/log/%s" % upload_id)
@ -3577,12 +3577,12 @@ class ServerAPIV1TestCase(unittest.TestCase):
"""Test starting a compose with upload settings"""
test_compose = {
"blueprint_name": "example-custom-base",
"compose_type": "vhd",
"compose_type": "ami",
"branch": "master",
"upload": {
"image_name": "Azure custom-base",
"provider": "azure",
"profile": test_profiles["azure"][0]
"image_name": "AWS custom-base",
"provider": "aws",
"profile": test_profiles["aws"][0]
}
}
resp = self.server.post("/api/v1/compose?test=2",
@ -3605,9 +3605,9 @@ class ServerAPIV1TestCase(unittest.TestCase):
print(data)
self.assertEqual(data["status"], True)
self.assertTrue("upload" in data)
self.assertEqual(data["upload"]["provider_name"], "azure")
self.assertEqual(data["upload"]["provider_name"], "aws")
self.assertEqual(data["upload"]["uuid"], upload_id)
self.assertEqual(data["upload"]["image_name"], "Azure custom-base")
self.assertEqual(data["upload"]["image_name"], "AWS custom-base")
# Get the upload log
resp = self.server.get("/api/v1/upload/log/%s" % upload_id)
@ -3630,7 +3630,7 @@ class ServerAPIV1TestCase(unittest.TestCase):
# Create a test compose
test_compose = {"blueprint_name": "example-custom-base",
"compose_type": "vhd",
"compose_type": "ami",
"branch": "master"}
resp = self.server.post("/api/v1/compose?test=2",
@ -3666,9 +3666,9 @@ class ServerAPIV1TestCase(unittest.TestCase):
# Schedule an upload of this image using settings
upload = {
"image_name": "Azure custom-base",
"provider": "azure",
"settings": test_profiles["azure"][1]
"image_name": "AWS custom-base",
"provider": "aws",
"settings": test_profiles["aws"][1]
}
resp = self.server.post("/api/v1/compose/uploads/schedule/%s" % build_id,
data=json.dumps(upload),
@ -3680,9 +3680,9 @@ class ServerAPIV1TestCase(unittest.TestCase):
# Schedule an upload of this image using settings
upload = {
"image_name": "Azure custom-base",
"provider": "azure",
"profile": test_profiles["azure"][0]
"image_name": "AWS custom-base",
"provider": "aws",
"profile": test_profiles["aws"][0]
}
resp = self.server.post("/api/v1/compose/uploads/schedule/%s" % build_id,
data=json.dumps(upload),
@ -3702,7 +3702,7 @@ class ServerAPIV1TestCase(unittest.TestCase):
def test_upload_06_providers_delete(self):
"""Delete a profile from a provider"""
# /api/v1/upload/providers/delete/provider/profile
resp = self.server.delete("/api/v1/upload/providers/delete/azure/%s" % test_profiles["azure"][0])
resp = self.server.delete("/api/v1/upload/providers/delete/aws/%s" % test_profiles["aws"][0])
data = json.loads(resp.data)
self.assertNotEqual(data, None)
self.assertEqual(data, {"status":True})
@ -3711,12 +3711,12 @@ class ServerAPIV1TestCase(unittest.TestCase):
resp = self.server.get("/api/v1/upload/providers")
data = json.loads(resp.data)
self.assertTrue("providers" in data)
self.assertTrue("azure" in data["providers"])
self.assertEqual(data["providers"]["azure"]["profiles"], {})
self.assertTrue("aws" in data["providers"])
self.assertEqual(data["providers"]["aws"]["profiles"], {})
def test_upload_07_delete_unknown_profile(self):
"""Delete an unknown profile"""
resp = self.server.delete("/api/v1/upload/providers/delete/azure/unknown")
resp = self.server.delete("/api/v1/upload/providers/delete/aws/unknown")
data = json.loads(resp.data)
self.assertNotEqual(data, None)
self.assertEqual(data["status"], False, "Failed to delete upload: %s" % data)