Add group-based tests.
This commit is contained in:
parent
5fe4b47072
commit
ab0655d5a9
1
tests/pylorax/results/groups-only.dict
Normal file
1
tests/pylorax/results/groups-only.dict
Normal file
@ -0,0 +1 @@
|
||||
{'description': u'An example e-mail server.', 'packages': [], 'groups': [{'name': u'mail-server'}], 'modules': [], 'version': u'0.0.1', 'name': u'mail-server'}
|
6
tests/pylorax/results/groups-only.toml
Normal file
6
tests/pylorax/results/groups-only.toml
Normal file
@ -0,0 +1,6 @@
|
||||
name = "mail-server"
|
||||
description = "An example e-mail server."
|
||||
version = "0.0.1"
|
||||
|
||||
[[groups]]
|
||||
name = "mail-server"
|
@ -184,7 +184,7 @@ class ProjectsTest(unittest.TestCase):
|
||||
def test_projects_depsolve(self):
|
||||
deps = projects_depsolve(self.yb, [("bash", "*.*")], [])
|
||||
self.assertTrue(len(deps) > 3)
|
||||
self.assertEqual(deps[2]["name"], "basesystem")
|
||||
self.assertTrue("basesystem" in [dep["name"] for dep in deps])
|
||||
|
||||
def test_projects_depsolve_version(self):
|
||||
"""Test that depsolving with a partial wildcard version works"""
|
||||
@ -225,13 +225,20 @@ class ProjectsTest(unittest.TestCase):
|
||||
self.assertTrue(len(modules) > 0)
|
||||
self.assertTrue(len(modules[0]["dependencies"]) > 3)
|
||||
self.assertEqual(modules[0]["name"], "bash")
|
||||
self.assertEqual(modules[0]["dependencies"][2]["name"], "basesystem")
|
||||
self.assertTrue("basesystem" in [dep["name"] for dep in modules[0]["dependencies"]])
|
||||
|
||||
def test_modules_info_yum_raises_exception(self):
|
||||
with self.assertRaises(ProjectsError):
|
||||
with mock.patch.object(self.yb, 'doPackageLists', side_effect=YumBaseError('TESTING')):
|
||||
modules_info(self.yb, ["bash"])
|
||||
|
||||
def test_groups_depsolve(self):
|
||||
deps = projects_depsolve(self.yb, [], ["base"])
|
||||
names = [grp["name"] for grp in deps]
|
||||
self.assertTrue("acl" in names) # mandatory package
|
||||
self.assertTrue("bash-completion" in names) # default package
|
||||
self.assertFalse("gpm" in names) # optional package
|
||||
|
||||
|
||||
class ConfigureTest(unittest.TestCase):
|
||||
@classmethod
|
||||
|
@ -32,6 +32,7 @@ class BasicRecipeTest(unittest.TestCase):
|
||||
("minimal.toml", "minimal.dict"),
|
||||
("modules-only.toml", "modules-only.dict"),
|
||||
("packages-only.toml", "packages-only.dict"),
|
||||
("groups-only.toml", "groups-only.dict"),
|
||||
("custom-base.toml", "custom-base.dict")]
|
||||
results_path = "./tests/pylorax/results/"
|
||||
self.input_toml = []
|
||||
@ -47,12 +48,16 @@ class BasicRecipeTest(unittest.TestCase):
|
||||
recipes.RecipeModule("httpd", "3.7.*")]
|
||||
self.old_packages = [recipes.RecipePackage("python", "2.7.*"),
|
||||
recipes.RecipePackage("parted", "3.2")]
|
||||
self.old_groups = [recipes.RecipeGroup("backup-client"),
|
||||
recipes.RecipeGroup("base")]
|
||||
self.new_modules = [recipes.RecipeModule("toml", "2.1"),
|
||||
recipes.RecipeModule("httpd", "3.8.*"),
|
||||
recipes.RecipeModule("openssh", "2.8.1")]
|
||||
self.new_packages = [recipes.RecipePackage("python", "2.7.*"),
|
||||
recipes.RecipePackage("parted", "3.2"),
|
||||
recipes.RecipePackage("git", "2.13.*")]
|
||||
self.new_groups = [recipes.RecipeGroup("console-internet"),
|
||||
recipes.RecipeGroup("base")]
|
||||
self.modules_result = [{"new": {"Modules": {"version": "2.8.1", "name": "openssh"}},
|
||||
"old": None},
|
||||
{"new": None,
|
||||
@ -60,6 +65,9 @@ class BasicRecipeTest(unittest.TestCase):
|
||||
{"new": {"Modules": {"version": "3.8.*", "name": "httpd"}},
|
||||
"old": {"Modules": {"version": "3.7.*", "name": "httpd"}}}]
|
||||
self.packages_result = [{"new": {"Packages": {"name": "git", "version": "2.13.*"}}, "old": None}]
|
||||
self.groups_result = [{'new': {'Groups': {'name': 'console-internet'}}, 'old': None},
|
||||
{'new': None, 'old': {'Groups': {'name': 'backup-client'}}}]
|
||||
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
@ -133,6 +141,7 @@ class BasicRecipeTest(unittest.TestCase):
|
||||
"""Test the diff_items function"""
|
||||
self.assertEqual(recipes.diff_items("Modules", self.old_modules, self.new_modules), self.modules_result)
|
||||
self.assertEqual(recipes.diff_items("Packages", self.old_packages, self.new_packages), self.packages_result)
|
||||
self.assertEqual(recipes.diff_items("Groups", self.old_groups, self.new_groups), self.groups_result)
|
||||
|
||||
def recipe_diff_test(self):
|
||||
"""Test the recipe_diff function"""
|
||||
|
@ -119,6 +119,7 @@ class ServerTestCase(unittest.TestCase):
|
||||
"packages": [{"name":"openssh-server", "version": "7.*"},
|
||||
{"name": "rsync", "version": "3.1.*"},
|
||||
{"name": "tmux", "version": "1.8"}],
|
||||
"groups": [],
|
||||
"version": "0.0.1"}]}
|
||||
resp = self.server.get("/api/v0/blueprints/info/http-server")
|
||||
data = json.loads(resp.data)
|
||||
@ -132,6 +133,7 @@ class ServerTestCase(unittest.TestCase):
|
||||
{"name":"glusterfs-cli", "version":"3.8.*"}],
|
||||
"name":"glusterfs",
|
||||
"packages":[{"name":"samba", "version":"4.7.*"}],
|
||||
"groups": [],
|
||||
"version": "0.0.1"},
|
||||
{"description":"An example http server with PHP and MySQL support.",
|
||||
"modules":[{"name":"httpd", "version":"2.4.*"},
|
||||
@ -143,6 +145,7 @@ class ServerTestCase(unittest.TestCase):
|
||||
"packages": [{"name":"openssh-server", "version": "7.*"},
|
||||
{"name": "rsync", "version": "3.1.*"},
|
||||
{"name": "tmux", "version": "1.8"}],
|
||||
"groups": [],
|
||||
"version": "0.0.1"},
|
||||
]}
|
||||
resp = self.server.get("/api/v0/blueprints/info/http-server,glusterfs")
|
||||
@ -186,7 +189,8 @@ class ServerTestCase(unittest.TestCase):
|
||||
"modules":[{"name":"glusterfs", "version":"3.8.*"},
|
||||
{"name":"glusterfs-cli", "version":"3.8.*"}],
|
||||
"packages":[{"name":"samba", "version":"4.7.*"},
|
||||
{"name":"tmux", "version":"1.8"}]}
|
||||
{"name":"tmux", "version":"1.8"}],
|
||||
"groups": []}
|
||||
|
||||
resp = self.server.post("/api/v0/blueprints/new",
|
||||
data=json.dumps(test_blueprint),
|
||||
@ -220,6 +224,12 @@ class ServerTestCase(unittest.TestCase):
|
||||
test_blueprint = toml.loads(test_blueprint)
|
||||
test_blueprint["version"] = "0.2.1"
|
||||
|
||||
# The test_blueprint generated by toml.loads will not have any groups property
|
||||
# defined, since there are no groups listed. However, /api/v0/blueprints/new will
|
||||
# return an object with groups=[]. So, add that here to keep the equality test
|
||||
# working.
|
||||
test_blueprint["groups"] = []
|
||||
|
||||
self.assertEqual(blueprints[0], test_blueprint)
|
||||
|
||||
def test_07_blueprints_ws_json(self):
|
||||
@ -230,7 +240,8 @@ class ServerTestCase(unittest.TestCase):
|
||||
"modules":[{"name":"glusterfs", "version":"3.8.*"},
|
||||
{"name":"glusterfs-cli", "version":"3.8.*"}],
|
||||
"packages":[{"name":"samba", "version":"4.7.*"},
|
||||
{"name":"tmux", "version":"1.8"}]}
|
||||
{"name":"tmux", "version":"1.8"}],
|
||||
"groups": []}
|
||||
|
||||
resp = self.server.post("/api/v0/blueprints/workspace",
|
||||
data=json.dumps(test_blueprint),
|
||||
@ -256,7 +267,8 @@ class ServerTestCase(unittest.TestCase):
|
||||
"modules":[{"name":"glusterfs", "version":"3.8.*"},
|
||||
{"name":"glusterfs-cli", "version":"3.8.*"}],
|
||||
"packages":[{"name":"samba", "version":"4.7.*"},
|
||||
{"name":"tmux", "version":"1.8"}]}
|
||||
{"name":"tmux", "version":"1.8"}],
|
||||
"groups": []}
|
||||
|
||||
resp = self.server.post("/api/v0/blueprints/workspace",
|
||||
data=json.dumps(test_blueprint),
|
||||
@ -478,7 +490,7 @@ class ServerTestCase(unittest.TestCase):
|
||||
self.assertNotEqual(data, None)
|
||||
deps = data.get("projects")
|
||||
self.assertEqual(len(deps) > 10, True)
|
||||
self.assertEqual(deps[2]["name"], "basesystem")
|
||||
self.assertTrue("basesystem" in [dep["name"] for dep in deps])
|
||||
|
||||
def test_projects_source_00_list(self):
|
||||
"""Test /api/v0/projects/source/list"""
|
||||
@ -632,7 +644,8 @@ class ServerTestCase(unittest.TestCase):
|
||||
modules = data.get("modules")
|
||||
self.assertEqual(len(modules), 1)
|
||||
self.assertEqual(modules[0]["name"], "bash")
|
||||
self.assertEqual(modules[0]["dependencies"][2]["name"], "basesystem")
|
||||
self.assertTrue("basesystem" in [dep["name"] for dep in modules[0]["dependencies"]])
|
||||
|
||||
|
||||
def test_blueprint_new_branch(self):
|
||||
"""Test the /api/v0/blueprints/new route with a new branch"""
|
||||
@ -642,7 +655,8 @@ class ServerTestCase(unittest.TestCase):
|
||||
"modules":[{"name":"glusterfs", "version":"3.8.*"},
|
||||
{"name":"glusterfs-cli", "version":"3.8.*"}],
|
||||
"packages":[{"name":"samba", "version":"4.7.*"},
|
||||
{"name":"tmux", "version":"1.8"}]}
|
||||
{"name":"tmux", "version":"1.8"}],
|
||||
"groups": []}
|
||||
|
||||
resp = self.server.post("/api/v0/blueprints/new?branch=test",
|
||||
data=json.dumps(test_blueprint),
|
||||
|
Loading…
Reference in New Issue
Block a user