Add group-based tests.

(cherry picked from commit ab0655d5a9)
(cherry picked from commit e151c8399d)
This commit is contained in:
Chris Lumens 2018-07-11 14:07:45 -04:00 committed by Brian C. Lane
parent 0259f3564d
commit dbeb653942
5 changed files with 45 additions and 9 deletions

View 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'}

View File

@ -0,0 +1,6 @@
name = "mail-server"
description = "An example e-mail server."
version = "0.0.1"
[[groups]]
name = "mail-server"

View File

@ -158,7 +158,7 @@ class ProjectsTest(unittest.TestCase):
def test_projects_depsolve(self):
deps = projects_depsolve(self.dbo, [("bash", "*.*")], [])
self.assertTrue(len(deps) > 3)
self.assertEqual(deps[0]["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"""
@ -195,6 +195,13 @@ class ProjectsTest(unittest.TestCase):
self.assertEqual(modules[0]["name"], "bash")
self.assertEqual(modules[0]["dependencies"][0]["name"], "basesystem")
def test_groups_depsolve(self):
deps = projects_depsolve(self.dbo, [], ["c-development"])
names = [grp["name"] for grp in deps]
self.assertTrue("autoconf" in names) # mandatory package
self.assertTrue("ctags" in names) # default package
self.assertFalse("cmake" in names) # optional package
class ConfigureTest(unittest.TestCase):
@classmethod

View File

@ -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("standard")]
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("standard")]
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"""

View File

@ -124,8 +124,9 @@ class ServerTestCase(unittest.TestCase):
{"name": "php-mysqlnd", "version":"7.2.4"}],
"name":"http-server",
"packages": [{"name":"openssh-server", "version": "7.*"},
{"name": "rsync", "version": "3.1.3"},
{"name": "rsync", "version": "3.1.*"},
{"name": "tmux", "version": "2.7"}],
"groups": [],
"version": "0.0.1"}]}
resp = self.server.get("/api/v0/blueprints/info/http-server")
data = json.loads(resp.data)
@ -141,6 +142,7 @@ class ServerTestCase(unittest.TestCase):
{"name":"glusterfs-cli", "version":"4.0.*"}],
"name":"glusterfs",
"packages":[{"name":"samba", "version":"4.8.*"}],
"groups": [],
"version": "0.0.1"},
{"description":"An example http server with PHP and MySQL support.",
"modules":[{"name":"httpd", "version":"2.4.*"},
@ -150,8 +152,9 @@ class ServerTestCase(unittest.TestCase):
{"name": "php-mysqlnd", "version":"7.2.4"}],
"name":"http-server",
"packages": [{"name":"openssh-server", "version": "7.*"},
{"name": "rsync", "version": "3.1.3"},
{"name": "rsync", "version": "3.1.*"},
{"name": "tmux", "version": "2.7"}],
"groups": [],
"version": "0.0.1"},
]}
resp = self.server.get("/api/v0/blueprints/info/http-server,glusterfs")
@ -197,7 +200,8 @@ class ServerTestCase(unittest.TestCase):
"modules":[{"name":"glusterfs", "version":"4.0.*"},
{"name":"glusterfs-cli", "version":"4.0.*"}],
"packages":[{"name":"samba", "version":"4.8.*"},
{"name":"tmux", "version":"2.7"}]}
{"name":"tmux", "version":"2.7"}],
"groups": []}
resp = self.server.post("/api/v0/blueprints/new",
data=json.dumps(test_blueprint),
@ -231,6 +235,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):
@ -241,7 +251,8 @@ class ServerTestCase(unittest.TestCase):
"modules":[{"name":"glusterfs", "version":"4.0.*"},
{"name":"glusterfs-cli", "version":"4.0.*"}],
"packages":[{"name":"samba", "version":"4.8.*"},
{"name":"tmux", "version":"2.7"}]}
{"name":"tmux", "version":"2.7"}],
"groups": []}
resp = self.server.post("/api/v0/blueprints/workspace",
data=json.dumps(test_blueprint),
@ -267,7 +278,8 @@ class ServerTestCase(unittest.TestCase):
"modules":[{"name":"glusterfs", "version":"4.0.*"},
{"name":"glusterfs-cli", "version":"4.0.*"}],
"packages":[{"name":"samba", "version":"4.8.*"},
{"name":"tmux", "version":"2.7"}]}
{"name":"tmux", "version":"2.7"}],
"groups": []}
resp = self.server.post("/api/v0/blueprints/workspace",
data=json.dumps(test_blueprint),
@ -491,7 +503,7 @@ class ServerTestCase(unittest.TestCase):
self.assertNotEqual(data, None)
deps = data.get("projects")
self.assertEqual(len(deps) > 10, True)
self.assertEqual(deps[0]["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"""
@ -654,7 +666,7 @@ class ServerTestCase(unittest.TestCase):
modules = data.get("modules")
self.assertEqual(len(modules) > 0, True)
self.assertEqual(modules[0]["name"], "bash")
self.assertEqual(modules[0]["dependencies"][0]["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"""
@ -664,7 +676,8 @@ class ServerTestCase(unittest.TestCase):
"modules":[{"name":"glusterfs", "version":"4.0.*"},
{"name":"glusterfs-cli", "version":"4.0.*"}],
"packages":[{"name":"samba", "version":"4.8.*"},
{"name":"tmux", "version":"2.7"}]}
{"name":"tmux", "version":"2.7"}],
"groups": []}
resp = self.server.post("/api/v0/blueprints/new?branch=test",
data=json.dumps(test_blueprint),