From 611ae4706f51d733f3c5924db630c16b163e96fe Mon Sep 17 00:00:00 2001 From: Petr Šabata Date: Nov 04 2016 11:26:37 +0000 Subject: Update the test suite to work with the new API Fewer files, more coverage. It's still not perfect but we're getting somewhere. Signed-off-by: Petr Šabata --- diff --git a/tests/basic.py b/tests/basic.py new file mode 100644 index 0000000..620d04b --- /dev/null +++ b/tests/basic.py @@ -0,0 +1,193 @@ +#/usr/bin/python3 +# -*- coding: utf-8 -*- + + +# Copyright (c) 2016 Red Hat, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Written by Petr Šabata + +import unittest + +import os +import sys + +DIR = os.path.dirname(__file__) +sys.path.insert(0, os.path.join(DIR, "..")) + +from modulemd import ModuleMetadata +from modulemd import supported_mdversions +from modulemd.profile import ModuleProfile +from modulemd.components.module import ModuleComponentModule +from modulemd.components.rpm import ModuleComponentRPM + +class TestBasic(unittest.TestCase): + @classmethod + def setUpClass(cls): + m = ModuleMetadata() + m.name = "name" + m.stream = "stream" + m.version = 1 + m.summary = "summary" + m.description = "description" + m.module_licenses = set(["module1", "module2", "module3"]) + m.content_licenses = set(["content1", "content2", "content3"]) + m.xmd = { "key" : "value" } + m.buildrequires = { + "br1" : "br1stream", + "br2" : "br2stream", + "br3" : "br3stream" + } + m.requires = { + "r1" : "r1stream", + "r2" : "r2stream", + "r3" : "r3stream" + } + m.community = "community" + m.documentation = "documentation" + m.tracker = "tracker" + profile = ModuleProfile() + profile.description = "description" + profile.rpms = set(["prof1", "prof2", "prof3"]) + m.profiles = { "profile" : profile } + m.api.rpms = set(["api1", "api2", "api3"]) + m.filter.rpms = set(["filter1", "filter2", "filter3"]) + rpm = ModuleComponentRPM("rpm", "rationale", + buildorder=1, + repository="repository", + commit="commit", + cache="cache", + arches=set(["arch1", "arch2", "arch3"]), + multilib=set(["multi1", "multi2", "multi3"]) + ) + m.components.rpms = { "rpm" : rpm } + mod = ModuleComponentModule("mod", "rationale", + buildorder=2, + repository="repository", + commit="commit", + ) + m.components.modules = { "mod" : mod } + cls.mmd = m + + def test_mdversion(self): + self.assertIn(self.mmd.mdversion, supported_mdversions) + + def test_name(self): + self.assertEqual(self.mmd.name, "name") + + def test_stream(self): + self.assertEqual(self.mmd.stream, "stream") + + def test_version(self): + self.assertEqual(self.mmd.version, 1) + + def test_summary(self): + self.assertEqual(self.mmd.summary, "summary") + + def test_description(self): + self.assertEqual(self.mmd.description, "description") + + def test_module_licenses(self): + self.assertSetEqual( + self.mmd.module_licenses, + set(["module1", "module2", "module3"]) + ) + + def test_content_licenses(self): + self.assertSetEqual( + self.mmd.content_licenses, + set(["content1", "content2", "content3"]) + ) + + def test_xmd(self): + self.assertDictEqual(self.mmd.xmd, { "key" : "value" }) + + def test_buildrequires(self): + self.assertDictEqual( + self.mmd.buildrequires, + { + "br1" : "br1stream", + "br2" : "br2stream", + "br3" : "br3stream" + } + ) + + def test_requires(self): + self.assertDictEqual( + self.mmd.requires, + { + "r1" : "r1stream", + "r2" : "r2stream", + "r3" : "r3stream" + } + ) + + def test_community(self): + self.assertEqual(self.mmd.community, "community") + + def test_documentation(self): + self.assertEqual(self.mmd.documentation, "documentation") + + def test_tracker(self): + self.assertEqual(self.mmd.tracker, "tracker") + + def test_profiles(self): + self.assertEqual(list(self.mmd.profiles.keys()), ["profile"]) + self.assertEqual( + self.mmd.profiles["profile"].description, + "description" + ) + self.assertSetEqual( + self.mmd.profiles["profile"].rpms, + set(["prof1", "prof2", "prof3"]) + ) + + def test_api(self): + self.assertSetEqual( + self.mmd.api.rpms, + set(["api1", "api2", "api3"]) + ) + + def test_filter(self): + self.assertSetEqual( + self.mmd.filter.rpms, + set(["filter1", "filter2", "filter3"]) + ) + + def test_rpms(self): + self.assertEqual(list(self.mmd.components.rpms.keys()), ["rpm"]) + rpm = self.mmd.components.rpms["rpm"] + self.assertEqual(rpm.name, "rpm") + self.assertEqual(rpm.rationale, "rationale") + self.assertEqual(rpm.buildorder, 1) + self.assertEqual(rpm.repository, "repository") + self.assertEqual(rpm.commit, "commit") + self.assertEqual(rpm.cache, "cache") + self.assertSetEqual(rpm.arches, set(["arch1", "arch2", "arch3"])) + self.assertSetEqual(rpm.multilib, set(["multi1", "multi2", "multi3"])) + + def test_modules(self): + self.assertEqual(list(self.mmd.components.modules.keys()), ["mod"]) + mod = self.mmd.components.modules["mod"] + self.assertEqual(mod.name, "mod") + self.assertEqual(mod.rationale, "rationale") + self.assertEqual(mod.buildorder, 2) + self.assertEqual(mod.repository, "repository") + self.assertEqual(mod.commit, "commit") diff --git a/tests/convenience.py b/tests/convenience.py new file mode 100644 index 0000000..9b7db7b --- /dev/null +++ b/tests/convenience.py @@ -0,0 +1,233 @@ +#/usr/bin/python3 +# -*- coding: utf-8 -*- + + +# Copyright (c) 2016 Red Hat, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Written by Petr Šabata + +import unittest + +import os +import sys + +DIR = os.path.dirname(__file__) +sys.path.insert(0, os.path.join(DIR, "..")) + +from modulemd import ModuleMetadata +from modulemd.profile import ModuleProfile +from modulemd.components.module import ModuleComponentModule +from modulemd.components.rpm import ModuleComponentRPM + +class TestConvenience(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.mmd = ModuleMetadata() + + def test_add_module_license(self): + self.assertSetEqual(self.mmd.module_licenses, set()) + self.mmd.add_module_license("test") + self.assertSetEqual(self.mmd.module_licenses, set(["test"])) + + def test_del_module_license(self): + self.mmd.module_licenses = set(["test"]) + self.mmd.del_module_license("test") + self.assertSetEqual(self.mmd.module_licenses, set()) + + def test_clear_module_licenses(self): + self.mmd.module_licenses = set(["test"]) + self.mmd.clear_module_licenses() + self.assertSetEqual(self.mmd.module_licenses, set()) + + def test_add_content_license(self): + self.assertSetEqual(self.mmd.content_licenses, set()) + self.mmd.add_content_license("test") + self.assertSetEqual(self.mmd.content_licenses, set(["test"])) + + def test_del_content_license(self): + self.mmd.content_licenses = set(["test"]) + self.mmd.del_content_license("test") + self.assertSetEqual(self.mmd.content_licenses, set()) + + def test_clear_content_licenses(self): + self.mmd.content_licenses = set(["test"]) + self.mmd.clear_content_licenses() + self.assertSetEqual(self.mmd.content_licenses, set()) + + def test_add_requires(self): + self.assertDictEqual(self.mmd.requires, dict()) + self.mmd.add_requires("key", "value") + self.assertDictEqual(self.mmd.requires, { "key" : "value" }) + + def test_update_requires(self): + self.assertDictEqual(self.mmd.requires, dict()) + self.mmd.update_requires("key", "value") + self.assertDictEqual(self.mmd.requires, { "key" : "value" }) + self.mmd.update_requires("key", "newvalue") + self.assertDictEqual(self.mmd.requires, { "key" : "newvalue" }) + + def test_del_requires(self): + self.mmd.requires = { "key" : "value" } + self.mmd.del_requires("key") + self.assertDictEqual(self.mmd.requires, dict()) + + def test_clear_requires(self): + self.mmd.requires = { "key" : "value" } + self.mmd.clear_requires() + self.assertDictEqual(self.mmd.requires, dict()) + + def test_add_buildrequires(self): + self.assertDictEqual(self.mmd.buildrequires, dict()) + self.mmd.add_buildrequires("key", "value") + self.assertDictEqual(self.mmd.buildrequires, { "key" : "value" }) + + def test_update_buildrequires(self): + self.assertDictEqual(self.mmd.buildrequires, dict()) + self.mmd.update_buildrequires("key", "value") + self.assertDictEqual(self.mmd.buildrequires, { "key" : "value" }) + self.mmd.update_buildrequires("key", "newvalue") + self.assertDictEqual(self.mmd.buildrequires, { "key" : "newvalue" }) + + def test_del_buildrequires(self): + self.mmd.buildrequires = { "key" : "value" } + self.mmd.del_buildrequires("key") + self.assertDictEqual(self.mmd.buildrequires, dict()) + + def test_clear_buildrequires(self): + self.mmd.buildrequires = { "key" : "value" } + self.mmd.clear_buildrequires() + self.assertDictEqual(self.mmd.buildrequires, dict()) + + def test_api_add_rpm(self): + self.assertSetEqual(self.mmd.api.rpms, set()) + self.mmd.api.add_rpm("test") + self.assertSetEqual(self.mmd.api.rpms, set(["test"])) + + def test_api_del_rpm(self): + self.mmd.api.rpms = set(["test"]) + self.mmd.api.del_rpm("test") + self.assertSetEqual(self.mmd.api.rpms, set()) + + def test_api_clear_rpms(self): + self.mmd.api.rpms = set(["test"]) + self.mmd.api.clear_rpms() + self.assertSetEqual(self.mmd.api.rpms, set()) + + def test_filter_add_rpm(self): + self.assertSetEqual(self.mmd.filter.rpms, set()) + self.mmd.filter.add_rpm("test") + self.assertSetEqual(self.mmd.filter.rpms, set(["test"])) + + def test_filter_del_rpm(self): + self.mmd.filter.rpms = set(["test"]) + self.mmd.filter.del_rpm("test") + self.assertSetEqual(self.mmd.filter.rpms, set()) + + def test_filter_clear_rpms(self): + self.mmd.filter.rpms = set(["test"]) + self.mmd.filter.clear_rpms() + self.assertSetEqual(self.mmd.filter.rpms, set()) + + def test_profile_add_rpm(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.assertSetEqual(self.mmd.profiles["test"].rpms, set()) + self.mmd.profiles["test"].add_rpm("test") + self.assertSetEqual(self.mmd.profiles["test"].rpms, set(["test"])) + + def test_profile_del_rpm(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.mmd.profiles["test"].rpms = set(["test"]) + self.mmd.profiles["test"].del_rpm("test") + self.assertSetEqual(self.mmd.profiles["test"].rpms, set()) + + def test_profile_clear_rpms(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.mmd.profiles["test"].rpms = set(["test"]) + self.mmd.profiles["test"].clear_rpms() + self.assertSetEqual(self.mmd.profiles["test"].rpms, set()) + + def test_components_all(self): + rpm = ModuleComponentRPM("rpm", "rationale") + mod = ModuleComponentModule("mod", "rationale") + self.mmd.components.rpms = { rpm.name : rpm } + self.mmd.components.modules = { mod.name : mod } + # XXX: It'd be nice if we could order these + self.assertListEqual(self.mmd.components.all, [rpm, mod]) + + def test_components_add_rpm(self): + self.assertDictEqual(self.mmd.components.rpms, dict()) + self.mmd.components.add_rpm("rpm", "rationale", buildorder=1, + repository="repository", commit="commit", cache="cache", + arches=set(["a1", "a2"]), multilib=set(["m1", "m2"])) + self.assertEqual(list(self.mmd.components.rpms.keys()), ["rpm"]) + self.assertIsInstance(self.mmd.components.rpms["rpm"], + ModuleComponentRPM) + self.assertEqual(self.mmd.components.rpms["rpm"].name, "rpm") + self.assertEqual(self.mmd.components.rpms["rpm"].rationale, "rationale") + self.assertEqual(self.mmd.components.rpms["rpm"].buildorder, 1) + self.assertEqual(self.mmd.components.rpms["rpm"].repository, "repository") + self.assertEqual(self.mmd.components.rpms["rpm"].commit, "commit") + self.assertEqual(self.mmd.components.rpms["rpm"].cache, "cache") + self.assertSetEqual(self.mmd.components.rpms["rpm"].arches, + set(["a1", "a2"])) + self.assertSetEqual(self.mmd.components.rpms["rpm"].multilib, + set(["m1", "m2"])) + + def test_components_del_rpm(self): + self.mmd.components.rpms = { + "rpm" : ModuleComponentRPM("rpm", "rationale") + } + self.mmd.components.del_rpm("rpm") + self.assertDictEqual(self.mmd.components.rpms, dict()) + + def test_components_clear_rpms(self): + self.mmd.components.rpms = { + "rpm" : ModuleComponentRPM("rpm", "rationale") + } + self.mmd.components.clear_rpms() + self.assertDictEqual(self.mmd.components.rpms, dict()) + + def test_components_add_module(self): + self.assertDictEqual(self.mmd.components.modules, dict()) + self.mmd.components.add_module("module", "rationale", buildorder=1, + repository="repository", commit="commit") + self.assertEqual(list(self.mmd.components.modules.keys()), ["module"]) + self.assertIsInstance(self.mmd.components.modules["module"], + ModuleComponentModule) + self.assertEqual(self.mmd.components.modules["module"].name, "module") + self.assertEqual(self.mmd.components.modules["module"].rationale, "rationale") + self.assertEqual(self.mmd.components.modules["module"].buildorder, 1) + self.assertEqual(self.mmd.components.modules["module"].repository, "repository") + self.assertEqual(self.mmd.components.modules["module"].commit, "commit") + + def test_components_del_module(self): + self.mmd.components.modules = { + "module" : ModuleComponentModule("module", "rationale") + } + self.mmd.components.del_module("module") + self.assertDictEqual(self.mmd.components.modules, dict()) + + def test_components_clear_modules(self): + self.mmd.components.modules = { + "module" : ModuleComponentModule("module", "rationale") + } + self.mmd.components.clear_modules() + self.assertDictEqual(self.mmd.components.modules, dict()) diff --git a/tests/io.py b/tests/io.py new file mode 100644 index 0000000..961b4dd --- /dev/null +++ b/tests/io.py @@ -0,0 +1,120 @@ +#/usr/bin/python3 +# -*- coding: utf-8 -*- + + +# Copyright (c) 2016 Red Hat, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Written by Petr Šabata + +import unittest + +import os +import sys + +DIR = os.path.dirname(__file__) +sys.path.insert(0, os.path.join(DIR, "..")) + +from modulemd import ModuleMetadata + +class TestIO(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.mmd = ModuleMetadata() + + def test_load_spec(self): + self.mmd.load("spec.yaml") + self.assertEqual(self.mmd.mdversion, 0) + self.assertEqual(self.mmd.name, "foo") + self.assertEqual(self.mmd.stream, "stream-name") + self.assertEqual(self.mmd.version, 20160927144203) + self.assertEqual(self.mmd.summary, "An example module") + self.assertEqual(self.mmd.description, "A module for the demonstration of the metadata format. Also, the obligatory lorem ipsum dolor sit amet goes right here.") + self.assertSetEqual(self.mmd.module_licenses, set(["MIT"])) + self.assertSetEqual(self.mmd.content_licenses, + set(["Beerware", "GPLv2+", "zlib"])) + self.assertIsNone(self.mmd.xmd) + self.assertDictEqual(self.mmd.buildrequires, + { + "generational-core" : "and-its-stream-name", + "generational-core-build" : "and-its-stream-name-too" + }) + self.assertDictEqual(self.mmd.requires, + { + "generational-core" : "and-its-stream-name" + }) + self.assertEqual(self.mmd.community, "http://www.example.com/") + self.assertEqual(self.mmd.documentation, "http://www.example.com/") + self.assertEqual(self.mmd.tracker, "http://www.example.com/") + self.assertSetEqual(set(self.mmd.profiles.keys()), + set(["default", "minimal"])) + self.assertSetEqual(self.mmd.profiles["default"].rpms, + set(["bar", "bar-extras", "baz"])) + self.assertEqual(self.mmd.profiles["minimal"].description, + "Minimal profile installing only the bar package.") + self.assertSetEqual(self.mmd.profiles["minimal"].rpms, + set(["bar"])) + self.assertSetEqual(self.mmd.api.rpms, + set(["bar", "bar-extras", "baz", "xxx"])) + self.assertSetEqual(self.mmd.filter.rpms, + set(["baz-nonfoo"])) + self.assertSetEqual(set(self.mmd.components.rpms.keys()), + set(["bar", "baz", "xxx", "xyz"])) + self.assertEqual(self.mmd.components.rpms["bar"].rationale, + "We need this to demonstrate stuff.") + self.assertEqual(self.mmd.components.rpms["bar"].repository, + "https://pagure.io/bar.git") + self.assertEqual(self.mmd.components.rpms["bar"].commit, + "26ca0c0") + self.assertEqual(self.mmd.components.rpms["bar"].cache, + "https://example.com/cache") + self.assertEqual(self.mmd.components.rpms["baz"].rationale, + "This one is here to demonstrate other stuff.") + self.assertEqual(self.mmd.components.rpms["xxx"].rationale, + "xxx demonstrates arches and multilib.") + self.assertSetEqual(self.mmd.components.rpms["xxx"].arches, + set(["i686", "x86_64"])) + self.assertSetEqual(self.mmd.components.rpms["xxx"].multilib, + set(["x86_64"])) + self.assertEqual(self.mmd.components.rpms["xyz"].rationale, + "xyz is a bundled dependency of xxx.") + self.assertEqual(self.mmd.components.rpms["xyz"].buildorder, + 10) + self.assertSetEqual(set(self.mmd.components.modules), + set(["includedmodule"])) + self.assertEqual(self.mmd.components.modules["includedmodule"].rationale, + "Included in the stack, just because.") + self.assertEqual(self.mmd.components.modules["includedmodule"].repository, + "https://pagure.io/includedmodule.git") + self.assertEqual(self.mmd.components.modules["includedmodule"].commit, + "98fe76d") + self.assertEqual(self.mmd.components.modules["includedmodule"].buildorder, + 100) + + def test_reload(self): + self.mmd.load("spec.yaml") + first = repr(self.mmd) + self.mmd.dump("testdump.yaml") + self.mmd = ModuleMetadata() + self.mmd.load("testdump.yaml") + second = repr(self.mmd) + self.assertEqual(first, second) + os.remove("testdump.yaml") diff --git a/tests/test.yaml b/tests/test.yaml deleted file mode 100644 index d7776b4..0000000 --- a/tests/test.yaml +++ /dev/null @@ -1,55 +0,0 @@ -document: modulemd -version: 0 -data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: - - MIT - content: - - GPL+ - - GPLv3 - xmd: - userid: userdata - dependencies: - buildrequires: - example: 84-84 - requires: - modulemd: 42-42 - references: - community: http://www.example.com/community - documentation: http://www.example.com/documentation - tracker: http://www.example.com/tracker - profiles: - default: - rpms: - - alfa - - alfa-subpackage - minimal: - description: Minimal profile installing only the alfa package. - rpms: - - alfa - api: - rpms: - - alfa - - alfa-extras - filter: - rpms: - - filter_1 - - filter_2 - components: - rpms: - packages: - alfa: - rationale: alfa rationale - bravo: - rationale: bravo rationale - arches: [ charlie, delta ] - multilib: [ echo ] - commit: foxtrot - repository: golf - cache: hotel diff --git a/tests/test_bad_input.py b/tests/test_bad_input.py deleted file mode 100755 index 835bd74..0000000 --- a/tests/test_bad_input.py +++ /dev/null @@ -1,248 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Jan Kaluza - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd -from yaml.scanner import ScannerError - -class TestIO(unittest.TestCase): - def test_invalid_yaml(self): - document = """ - document: modulemd - version: 0 - data - """ - mmd = modulemd.ModuleMetadata() - # Python yaml module raises wrong error message with "found" string - # instead of "find". We are testing for both variants here. - self.assertRaisesRegexp(ScannerError, - r"could not f(?:ou|i)nd expected ':'", - mmd.loads, document) - - def test_object_value(self, yaml=None, value=""): - """ - Replaces $VALUE in the the `yaml` input with the value provided - in the `value` variable and loads the yaml using modulemd library. - """ - if not yaml: - return - - yaml = yaml.replace("$VALUE", value) - mmd = modulemd.ModuleMetadata() - mmd.loads(yaml) - mmd.validate() - - def test_object_missing(self, yaml=None): - """ - Removes the line with the $VALUE from the yaml input and - loads the yaml using modulemd library. - """ - if not yaml: - return - - yaml = "\n".join(n for n in yaml.split("\n") if "$VALUE" not in n) - mmd = modulemd.ModuleMetadata() - mmd.loads(yaml) - mmd.validate() - - def test_document(self): - document = """ - document: $VALUE - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - content: [ GPL+, GPLv3 ] - """ - self.assertRaisesRegexp(ValueError, - "The supplied data isn't a valid modulemd document", - self.test_object_missing, document) - for value in ["", "modulemd2", "[]", "{}"]: - self.assertRaisesRegexp(ValueError, - "The supplied data isn't a valid modulemd document", - self.test_object_value, document, value) - - def test_mdversion(self): - document = """ - document: modulemd - version: $VALUE - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - content: [ GPL+, GPLv3 ] - """ - self.assertRaisesRegexp(ValueError, ".* is required", - self.test_object_missing, document) - for value in ["", "unknown", "[]", "{}", "9999"]: - self.assertRaisesRegexp(ValueError, - "The supplied metadata version isn't supported", - self.test_object_value, document, value) - - def test_data(self): - document = """ - document: modulemd - version: 0 - data: $VALUE - """ - self.assertRaisesRegexp(ValueError, ".* is required", - self.test_object_missing, document) - for value in ["", "unknown", "[]", "9999"]: - self.assertRaisesRegexp(ValueError, - ".* is required", - self.test_object_value, document, value) - - def test_summary(self): - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: $VALUE - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - content: [ GPL+, GPLv3 ] - """ - self.assertRaisesRegexp(ValueError, - "summary is required", - self.test_object_missing, document) - for value in ["", "test", "[]", "{}", "1"]: - self.test_object_value(document, value) - - def test_description(self): - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: $VALUE - license: - module: [ MIT ] - content: [ GPL+, GPLv3 ] - """ - self.assertRaisesRegexp(ValueError, - "description is required", - self.test_object_missing, document) - for value in ["", "test", "[]", "{}", "1"]: - self.test_object_value(document, value) - - def test_license(self): - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: $VALUE - license: $VALUE - """ - self.assertRaisesRegexp(ValueError, - "description is required", - self.test_object_missing, document) - - values = ["", "test", "1", "[]", "{}"] - values += ["{content:[MIT, GPL]}", "{module: []}"] - values += ["{module: }", "{module: {}}"] - - for value in values: - self.assertRaisesRegexp(ValueError, - "at least one module license is required", - self.test_object_value, document, value) - - self.test_object_value(document, "{module: [MIT]}") - self.test_object_value(document, "{module: MIT}") - - def test_dependencies(self): - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - dependencies: $VALUE - """ - self.test_object_missing(document) - for value in ["", "test", "1", "[]", "{}"]: - self.test_object_value(document, value) - - def test_dependencies_type(self): - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - dependencies: - requires: $VALUE - """ - self.test_object_value(document, "") - self.test_object_value(document, "[]") - self.test_object_value(document, "{}") - self.assertRaisesRegexp(TypeError, "Incorrect data type passed", - self.test_object_value, document, "[foo, bar]") - self.test_object_value(document, "{modulemd: 42-42}") - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_basic.py b/tests/test_basic.py deleted file mode 100755 index f2e1a2f..0000000 --- a/tests/test_basic.py +++ /dev/null @@ -1,132 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestBasic(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.mmd = modulemd.ModuleMetadata() - cls.mmd.name = "test" - cls.mmd.stream= "42" - cls.mmd.version = 1 - cls.mmd.summary = "A test module" - cls.mmd.description = "It's only used for testing purposes." - cls.mmd.module_licenses = set([ "MIT" ]) - cls.mmd.content_licenses = set([ "ISC" ]) - cls.mmd.buildrequires = { "builddepenency" : "123-456" } - cls.mmd.requires = { "dependency" : "1.00-1" } - cls.mmd.community = "http://www.example.com/community" - cls.mmd.documentation = "http://www.example.com/documentation" - cls.mmd.tracker = "http://www.example.com/tracker" - cls.mmd.xmd = { "key" : "value" } - cls.mmd.profiles = { "default" : modulemd.ModuleProfile() } - cls.mmd.profiles["default"].rpms = set([ "prof", "ile" ]) - cls.mmd.profiles["default"].description = "Default set of packages" - cls.mmd.api = modulemd.ModuleAPI() - cls.mmd.api.rpms = set([ "api" ]) - cls.mmd.filter = modulemd.ModuleFilter() - cls.mmd.filter.rpms = set([ "filter_1", "filter_2" ]) - cls.mmd.components = modulemd.ModuleComponents() - cls.mmd.components.rpms = modulemd.ModuleRPMs() - cls.mmd.components.rpms.api = set([ "api" ]) - cls.mmd.components.rpms.packages = { "rpm" : { "rationale" : "" } } - cls.mmd.components.rpms.filter = set([ "filter_1", "filter_2" ]) - - def test_mdversion(self): - self.assertIn(self.mmd.mdversion, modulemd.supported_mdversions) - - def test_name(self): - self.assertEqual(self.mmd.name, "test") - - def test_stream(self): - self.assertEqual(self.mmd.stream, "42") - - def test_version(self): - self.assertEqual(self.mmd.version, 1) - - def test_summary(self): - self.assertEqual(self.mmd.summary, "A test module") - - def test_description(self): - self.assertEqual(self.mmd.description, "It's only used for testing purposes.") - - def test_module_licenses(self): - self.assertEqual(self.mmd.module_licenses, set(["MIT"])) - - def test_content_licenses(self): - self.assertEqual(self.mmd.content_licenses, set(["ISC"])) - - def test_buildrequires(self): - self.assertEqual(self.mmd.buildrequires, {"builddepenency" : "123-456"}) - - def test_requires(self): - self.assertEqual(self.mmd.requires, {"dependency" : "1.00-1"}) - - def test_community(self): - self.assertEqual(self.mmd.community, "http://www.example.com/community") - - def test_documentation(self): - self.assertEqual(self.mmd.documentation, "http://www.example.com/documentation") - - def test_tracker(self): - self.assertEqual(self.mmd.tracker, "http://www.example.com/tracker") - - def test_xmd(self): - self.assertEqual(self.mmd.xmd, { "key" : "value" }) - - def test_profiles(self): - self.assertEqual(list(self.mmd.profiles.keys()), ["default"]) - - def test_api(self): - self.assertEqual(self.mmd.api.rpms, set(["api"])) - - def test_filter(self): - self.assertSetEqual(self.mmd.filter.rpms, set(["filter_1", "filter_2"])) - - def test_profiles_rpms(self): - self.assertEqual(self.mmd.profiles["default"].rpms, set(["prof", "ile"])) - self.assertEqual(self.mmd.profiles["default"].description, "Default set of packages") - - def test_components(self): - self.assertIsInstance(self.mmd.components, modulemd.ModuleComponents) - - def test_rpms(self): - self.assertIsInstance(self.mmd.components.rpms, modulemd.ModuleRPMs) - - def test_rpm_packages(self): - self.assertEqual(self.mmd.components.rpms.packages, { "rpm" : { "rationale" : "" } }) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_content.py b/tests/test_content.py deleted file mode 100755 index bfd09da..0000000 --- a/tests/test_content.py +++ /dev/null @@ -1,64 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestContent(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.mc = modulemd.ModuleContent() - - def test_add_package(self): - self.mc.packages = dict() - self.mc.add_package("Add") - self.assertEqual(self.mc.packages, { "Add" : { "rationale" : "" } } ) - - def test_add_package_with_rationale(self): - self.mc.packages = dict() - self.mc.add_package("AddWithRationale", "rationalestr") - self.assertEqual(self.mc.packages, - { "AddWithRationale" : { "rationale" : "rationalestr" } } ) - - def test_del_package(self): - self.mc.packages = { "Del" : None } - self.mc.del_package("Del") - self.assertEqual(self.mc.packages, dict()) - - def test_clear_packages(self): - self.mc.packages = { "Clear" : None } - self.mc.clear_packages() - self.assertEqual(self.mc.packages, dict()) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_dependencies.py b/tests/test_dependencies.py deleted file mode 100755 index 6f6d226..0000000 --- a/tests/test_dependencies.py +++ /dev/null @@ -1,96 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestDependencies(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.mmd = modulemd.ModuleMetadata() - - def test_add_buildrequires(self): - self.mmd.buildrequires = dict() - self.mmd.add_buildrequires("AddBRName", "AddBRStream") - self.assertEqual(self.mmd.buildrequires, { "AddBRName" : "AddBRStream" }) - - def test_add_buildrequires_numeric(self): - self.mmd.buildrequires = dict() - self.mmd.buildrequires = { "AddBRNumeric" : 1 } - self.assertEqual(self.mmd.buildrequires, { "AddBRNumeric" : "1" }) - - def test_update_buildrequires(self): - self.mmd.buildrequires = dict() - self.mmd.update_buildrequires("UpdateBRName", "UpdateBRStream") - self.assertEqual(self.mmd.buildrequires, { "UpdateBRName" : "UpdateBRStream" }) - self.mmd.update_buildrequires("UpdateBRName", "UpdateBRStream-1") - self.assertEqual(self.mmd.buildrequires, { "UpdateBRName" : "UpdateBRStream-1" }) - - def test_del_buildrequires(self): - self.mmd.buildrequires = { "DelBRName" : "DelBRStream" } - self.mmd.del_buildrequires("DelBRName") - self.assertEqual(self.mmd.buildrequires, dict()) - - def test_clear_buildrequires(self): - self.mmd.buildrequires = { "ClearBRName" : "ClearBRStream" } - self.mmd.clear_buildrequires() - - def test_add_requires(self): - self.mmd.requires = dict() - self.mmd.add_requires("AddRName", "AddRStream") - self.assertEqual(self.mmd.requires, { "AddRName" : "AddRStream" }) - - def test_add_requires_numeric(self): - self.mmd.requires = dict() - self.mmd.requires = { "AddRNumeric" : 1 } - self.assertEqual(self.mmd.requires, { "AddRNumeric" : "1" }) - - def test_update_requires(self): - self.mmd.requires = dict() - self.mmd.update_requires("UpdateRName", "UpdateRStream") - self.assertEqual(self.mmd.requires, { "UpdateRName" : "UpdateRStream" }) - self.mmd.update_requires("UpdateRName", "UpdateRStream-1") - self.assertEqual(self.mmd.requires, { "UpdateRName" : "UpdateRStream-1" }) - - def test_del_requires(self): - self.mmd.requires = { "DelRName" : "DelRStream" } - self.mmd.del_requires("DelRName") - self.assertEqual(self.mmd.requires, dict()) - - def test_clear_requires(self): - self.mmd.requires = { "ClearRName" : "ClearRStream" } - self.mmd.clear_requires() - self.assertEqual(self.mmd.requires, dict()) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_io.py b/tests/test_io.py deleted file mode 100755 index e8ebb28..0000000 --- a/tests/test_io.py +++ /dev/null @@ -1,227 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestIO(unittest.TestCase): - def test_load(self, filename="tests/test.yaml"): - mmd = modulemd.ModuleMetadata() - mmd.load(filename) - self.assertEqual(mmd.mdversion, 0) - self.assertEqual(mmd.name, "test") - self.assertEqual(mmd.stream, "1.23") - self.assertEqual(mmd.version, 4) - self.assertEqual(mmd.summary, "A test module") - self.assertEqual(mmd.description, - "This module is a part of the modulemd test suite.") - self.assertEqual(mmd.module_licenses, set(["MIT"])) - self.assertEqual(mmd.content_licenses, set(["GPL+", "GPLv3"])) - self.assertEqual(mmd.buildrequires, {"example" : "84-84"}) - self.assertEqual(mmd.requires, {"modulemd" : "42-42"}) - self.assertEqual(mmd.community, "http://www.example.com/community") - self.assertEqual(mmd.documentation, "http://www.example.com/documentation") - self.assertEqual(mmd.tracker, "http://www.example.com/tracker") - self.assertEqual(mmd.xmd, { "userid" : "userdata" }) - self.assertEqual(sorted(mmd.profiles.keys()), ["default", "minimal"]) - self.assertEqual(mmd.profiles["default"].rpms, set(["alfa", "alfa-subpackage"])) - self.assertEqual(mmd.profiles["minimal"].description, "Minimal profile installing only the alfa package.") - self.assertEqual(mmd.profiles["minimal"].rpms, set(["alfa"])) - self.assertEqual(mmd.api.rpms, set(["alfa", "alfa-extras"])) - self.assertEqual(mmd.filter.rpms, set(["filter_1", "filter_2"])) - self.assertEqual(mmd.components.rpms.packages, - { "alfa" : { "rationale" : "alfa rationale" }, - "bravo" : { "rationale" : "bravo rationale", - "arches" : [ "charlie", "delta" ], - "multilib" : [ "echo" ], - "commit" : "foxtrot", - "repository" : "golf", - "cache" : "hotel" } } ) - - def test_loads(self, yaml=None): - mmd = modulemd.ModuleMetadata() - document = """ - document: modulemd - version: 0 - data: - name: test - stream: 1.23 - version: 4 - summary: A test module - description: > - This module is a part of the modulemd test suite. - license: - module: [ MIT ] - content: [ GPL+, GPLv3 ] - dependencies: - buildrequires: { example: 84-84 } - requires: { modulemd: 42-42 } - references: - community: http://www.example.com/community - documentation: http://www.example.com/documentation - tracker: http://www.example.com/tracker - xmd: - userid: userdata - profiles: - default: - rpms: - - alfa - - alfa-subpackage - minimal: - description: Minimal profile installing only the alfa package. - rpms: - - alfa - api: - rpms: - - alfa - - alfa-extras - filter: - rpms: - - filter_1 - - filter_2 - components: - rpms: - packages: - alfa: - rationale: alfa rationale - bravo: - rationale: bravo rationale - arches: [ charlie, delta ] - multilib: [ echo ] - commit: foxtrot - repository: golf - cache: hotel - """ - if not yaml: - yaml = document - mmd.loads(yaml) - self.assertEqual(mmd.mdversion, 0) - self.assertEqual(mmd.name, "test") - self.assertEqual(mmd.stream, "1.23") - self.assertEqual(mmd.version, 4) - self.assertEqual(mmd.summary, "A test module") - self.assertEqual(mmd.description, - "This module is a part of the modulemd test suite.") - self.assertEqual(mmd.module_licenses, set(["MIT"])) - self.assertEqual(mmd.content_licenses, set(["GPL+", "GPLv3"])) - self.assertEqual(mmd.buildrequires, {"example" : "84-84"}) - self.assertEqual(mmd.requires, {"modulemd" : "42-42"}) - self.assertEqual(mmd.community, "http://www.example.com/community") - self.assertEqual(mmd.documentation, "http://www.example.com/documentation") - self.assertEqual(mmd.tracker, "http://www.example.com/tracker") - self.assertEqual(mmd.xmd, { "userid" : "userdata" }) - self.assertEqual(sorted(mmd.profiles.keys()), ["default", "minimal"]) - self.assertEqual(mmd.profiles["default"].rpms, set(["alfa", "alfa-subpackage"])) - self.assertEqual(mmd.profiles["minimal"].description, - "Minimal profile installing only the alfa package.") - self.assertEqual(mmd.profiles["minimal"].rpms, set(["alfa"])) - self.assertEqual(mmd.api.rpms, set(["alfa", "alfa-extras"])) - self.assertEqual(mmd.filter.rpms, set(["filter_1", "filter_2"])) - self.assertEqual(mmd.components.rpms.packages, - { "alfa" : { "rationale" : "alfa rationale" }, - "bravo" : { "rationale" : "bravo rationale", - "arches" : [ "charlie", "delta" ], - "multilib" : [ "echo" ], - "commit" : "foxtrot", - "repository" : "golf", - "cache" : "hotel" } } ) - - def test_dump(self): - mmd = modulemd.ModuleMetadata() - mmd.mdversion = 0 - mmd.name = "test" - mmd.stream = "1.23" - mmd.version = 4 - mmd.summary = "A test module" - mmd.description = "This module is a part of the modulemd test suite." - mmd.add_module_license("MIT") - mmd.add_content_license("GPL+") - mmd.add_content_license("GPLv3") - mmd.add_buildrequires("example", "84-84") - mmd.add_requires("modulemd", "42-42") - mmd.community = "http://www.example.com/community" - mmd.documentation = "http://www.example.com/documentation" - mmd.tracker = "http://www.example.com/tracker" - mmd.xmd = { "userid" : "userdata" } - mmd.profiles = { "default" : modulemd.ModuleProfile(), "minimal" : modulemd.ModuleProfile() } - mmd.profiles["default"].rpms = set(["alfa", "alfa-subpackage"]) - mmd.profiles["minimal"].rpms = set(["alfa"]) - mmd.profiles["minimal"].description = "Minimal profile installing only the alfa package." - mmd.api = modulemd.ModuleAPI() - mmd.api.rpms = set(["alfa", "alfa-extras"]) - mmd.filter = modulemd.ModuleFilter() - mmd.filter.rpms = set(["filter_1", "filter_2"]) - mmd.components = modulemd.ModuleComponents() - mmd.components.rpms = modulemd.ModuleRPMs() - mmd.components.rpms.add_package("alfa", rationale="alfa rationale") - mmd.components.rpms.add_package("bravo", rationale="bravo rationale", - arches=["charlie", "delta"], multilib=["echo"], - commit="foxtrot", repository="golf", cache="hotel") - mmd.dump("tests/dump.yaml") - self.test_load(filename="tests/dump.yaml") - - def test_dumps(self): - mmd = modulemd.ModuleMetadata() - mmd.mdversion = 0 - mmd.name = "test" - mmd.stream = "1.23" - mmd.version = 4 - mmd.summary = "A test module" - mmd.description = "This module is a part of the modulemd test suite." - mmd.add_module_license("MIT") - mmd.add_content_license("GPL+") - mmd.add_content_license("GPLv3") - mmd.add_buildrequires("example", "84-84") - mmd.add_requires("modulemd", "42-42") - mmd.community = "http://www.example.com/community" - mmd.documentation = "http://www.example.com/documentation" - mmd.tracker = "http://www.example.com/tracker" - mmd.xmd = { "userid" : "userdata" } - mmd.profiles = { "default" : modulemd.ModuleProfile(), "minimal" : modulemd.ModuleProfile() } - mmd.profiles["default"].rpms = set(["alfa", "alfa-subpackage"]) - mmd.profiles["minimal"].rpms = set(["alfa"]) - mmd.profiles["minimal"].description = "Minimal profile installing only the alfa package." - mmd.api = modulemd.ModuleAPI() - mmd.api.rpms = set(["alfa", "alfa-extras"]) - mmd.filter = modulemd.ModuleFilter() - mmd.filter.rpms = set(["filter_1", "filter_2"]) - mmd.components = modulemd.ModuleComponents() - mmd.components.rpms = modulemd.ModuleRPMs() - mmd.components.rpms.add_package("alfa", rationale="alfa rationale") - mmd.components.rpms.add_package("bravo", rationale="bravo rationale", - arches=["charlie", "delta"], multilib=["echo"], - commit="foxtrot", repository="golf", cache="hotel") - self.test_loads(yaml=mmd.dumps()) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_licenses.py b/tests/test_licenses.py deleted file mode 100755 index 5eb6daa..0000000 --- a/tests/test_licenses.py +++ /dev/null @@ -1,73 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestLicenses(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.mmd = modulemd.ModuleMetadata() - - def test_add_module_license(self): - self.assertNotIn("AddModuleLicense", self.mmd.module_licenses) - self.mmd.add_module_license("AddModuleLicense") - self.assertIn("AddModuleLicense", self.mmd.module_licenses) - - def test_del_module_license(self): - self.mmd.module_licenses = set(["DelModuleLicense"]) - self.mmd.del_module_license("DelModuleLicense") - self.assertNotIn("DelModuleLicense", self.mmd.module_licenses) - - def test_clear_module_licenses(self): - self.mmd.module_licenses = set(["ClearModuleLicenses"]) - self.mmd.clear_module_licenses() - self.assertEqual(self.mmd.module_licenses, set([])) - - def test_add_content_license(self): - self.assertNotIn("AddContentLicense", self.mmd.content_licenses) - self.mmd.add_content_license("AddContentLicense") - self.assertIn("AddContentLicense", self.mmd.content_licenses) - - def test_del_content_license(self): - self.mmd.content_licenses = set(["DelContentLicense"]) - self.mmd.del_content_license("DelContentLicense") - self.assertNotIn("DelContentLicense", self.mmd.content_licenses) - - def test_clear_content_licenses(self): - self.mmd.content_licenses = set(["ClearContentLicenses"]) - self.mmd.clear_content_licenses() - self.assertEqual(self.mmd.content_licenses, set([])) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_rpms.py b/tests/test_rpms.py deleted file mode 100755 index 9fcd27a..0000000 --- a/tests/test_rpms.py +++ /dev/null @@ -1,94 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestRPMs(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.mr = modulemd.ModuleRPMs() - - def test_add_package(self): - self.mr.packages = dict() - self.mr.add_package("Add") - self.assertEqual(self.mr.packages, { "Add" : { "rationale" : "" } } ) - - def test_add_package_with_rationale(self): - self.mr.packages = dict() - self.mr.add_package("AddWithRationale", rationale="rationalestr") - self.assertEqual(self.mr.packages, - { "AddWithRationale" : { "rationale" : "rationalestr" } } ) - - def test_add_package_with_arches(self): - self.mr.packages = dict() - self.mr.add_package("AddWithArches", arches=["x", "y", "z"]) - self.assertEqual(self.mr.packages, - { "AddWithArches" : { "rationale" : "", "arches" : ["x", "y", "z"] } } ) - - def test_add_package_with_multilib(self): - self.mr.packages = dict() - self.mr.add_package("AddWithMultilib", multilib=["x", "y", "z"]) - self.assertEqual(self.mr.packages, - { "AddWithMultilib" : { "rationale" : "", "multilib" : ["x", "y", "z"] } } ) - - def test_add_package_with_commit(self): - self.mr.packages = dict() - self.mr.add_package("AddWithCommit", commit="commitstr") - self.assertEqual(self.mr.packages, - { "AddWithCommit" : { "rationale" : "", "commit" : "commitstr"} } ) - - def test_add_package_with_repository(self): - self.mr.packages = dict() - self.mr.add_package("AddWithRepository", repository="repostr") - self.assertEqual(self.mr.packages, - { "AddWithRepository" : { "rationale" : "", "repository" : "repostr" } } ) - - def test_add_package_with_cache(self): - self.mr.packages = dict() - self.mr.add_package("AddWithCache", cache="cachestr") - self.assertEqual(self.mr.packages, - { "AddWithCache" : { "rationale" : "", "cache" : "cachestr" } } ) - - def test_del_package(self): - self.mr.packages = { "Del" : None } - self.mr.del_package("Del") - self.assertEqual(self.mr.packages, dict()) - - def test_clear_packages(self): - self.mr.packages = { "Clear" : None } - self.mr.clear_packages() - self.assertEqual(self.mr.packages, dict()) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_validate.py b/tests/test_validate.py deleted file mode 100755 index 430d173..0000000 --- a/tests/test_validate.py +++ /dev/null @@ -1,231 +0,0 @@ -#/usr/bin/python3 -# -*- coding: utf-8 -*- - - -# Copyright (c) 2016 Red Hat, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Written by Petr Šabata - -import unittest - -import os -import sys - -DIR = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(DIR, "..")) - -import modulemd - -class TestValidate(unittest.TestCase): - def setUp(self): - self.mmd = modulemd.ModuleMetadata() - self.mmd.load("tests/test.yaml") - - def test_validate_mdversion(self): - self.mmd._mdversion = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_name(self): - self.mmd._name = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_stream(self): - self.mmd._stream = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_version(self): - self.mmd._version = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_summary1(self): - self.mmd._summary = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_summary2(self): - self.mmd.summary = "" - self.assertRaises(ValueError, self.mmd.validate) - - def test_validate_description1(self): - self.mmd._description = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_description2(self): - self.mmd.description = "" - self.assertRaises(ValueError, self.mmd.validate) - - def test_validate_module_licenses1(self): - self.mmd._module_licenses = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_module_licenses2(self): - self.mmd._module_licenses = set([1, 2, 3]) - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_module_licenses3(self): - self.mmd.clear_module_licenses() - self.assertRaises(ValueError, self.mmd.validate) - - def test_validate_content_licenses1(self): - self.mmd._content_licenses = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_content_licenses2(self): - self.mmd._content_licenses = set([1, 2, 3]) - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_requires1(self): - self.mmd._requires = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_requires2(self): - self.mmd._requires = { "foo" : 1 } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_requires3(self): - self.mmd._requires = { 1 : "foo" } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_requires4(self): - self.mmd._requires = { 1 : 2 } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_community(self): - self.mmd._community = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_documentation(self): - self.mmd._documentation = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_tracker(self): - self.mmd._tracker = None - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_xmd(self): - self.mmd._xmd = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles1(self): - self.mmd._profiles = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles2(self): - self.mmd.profiles = { 1 : modulemd.ModuleProfile() } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles3(self): - self.mmd.profiles = { "foo" : 1 } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles4(self): - self.mmd.profiles = { "foo" : modulemd.ModuleProfile() } - self.mmd.profiles["foo"]._rpms = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles5(self): - self.mmd.profiles = { "foo" : modulemd.ModuleProfile() } - self.mmd.profiles["foo"]._rpms = set([1, 2, 3]) - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles6(self): - self.mmd.profiles = { "foo" : modulemd.ModuleProfile() } - self.mmd.profiles["foo"]._description = {} - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_profiles7(self): - self.mmd.profiles = { "foo" : modulemd.ModuleProfile() } - self.mmd.profiles["foo"]._description = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_api(self): - self.mmd._api = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_api_rpms(self): - self.mmd.api._rpms = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_filter(self): - self.mmd._filter = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_filter_rpms(self): - self.mmd.filter._rpms = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_components(self): - self.mmd._components = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms(self): - self.mmd.components._rpms = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages1(self): - self.mmd.components.rpms._packages = 1 - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages2(self): - self.mmd.components.rpms._packages = { "foo" : 1 } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages3(self): - self.mmd.components.rpms._packages = { "foo" : dict() } - self.assertRaises(ValueError, self.mmd.validate) - - def test_validate_rpms_packages4(self): - self.mmd.components.rpms._packages = { 1 : None } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages5(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", 1 : None } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages6(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale": "", "arches" : 1 } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages7(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "arches" : [1, 2, 3] } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages8(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "multilib" : 1 } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages9(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "multilib" : [1, 2, 3] } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages10(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "commit" : 1 } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages11(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "repository" : 1 } } - self.assertRaises(TypeError, self.mmd.validate) - - def test_validate_rpms_packages12(self): - self.mmd.components.rpms._packages = { "foo" : { "rationale" : "", "cache" : 1 } } - self.assertRaises(TypeError, self.mmd.validate) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/validation.py b/tests/validation.py new file mode 100644 index 0000000..cbae8c4 --- /dev/null +++ b/tests/validation.py @@ -0,0 +1,257 @@ +#/usr/bin/python3 +# -*- coding: utf-8 -*- + + +# Copyright (c) 2016 Red Hat, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Written by Petr Šabata + +import unittest + +import os +import sys + +DIR = os.path.dirname(__file__) +sys.path.insert(0, os.path.join(DIR, "..")) + +from modulemd import ModuleMetadata +from modulemd import supported_mdversions +from modulemd.profile import ModuleProfile +from modulemd.components.base import ModuleComponentBase +from modulemd.components.module import ModuleComponentModule +from modulemd.components.rpm import ModuleComponentRPM + +class TestValidation(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.mmd = ModuleMetadata() + + def test_mdversion_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "mdversion", "") + + def test_mdversion_value(self): + self.assertRaises(ValueError, setattr, self.mmd, "mdversion", -1) + + def test_name_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "name", 0) + + def test_stream_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "stream", 0) + + def test_version_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "version", "") + + def test_summary_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "summary", 0) + + def test_description_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "description", 0) + + def test_module_license_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "module_licenses", 0) + + def test_module_license_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd, "module_licenses", + set([1, 2, 3])) + + def test_content_license_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "content_licenses", 0) + + def test_content_license_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd, "content_licenses", + set([1, 2, 3])) + + def test_xmd_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "xmd", 0) + + def test_buildrequires_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "buildrequires", 0) + + def test_buildrequires_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd, "buildrequires", + { "key" : 0 } ) + self.assertRaises(TypeError, setattr, self.mmd, "buildrequires", + { 0 : "value" } ) + self.assertRaises(TypeError, setattr, self.mmd, "buildrequires", + { 0 : 0 } ) + + def test_requires_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "requires", 0) + + def test_requires_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd, "requires", + { "key" : 0 } ) + self.assertRaises(TypeError, setattr, self.mmd, "requires", + { 0 : "value" } ) + self.assertRaises(TypeError, setattr, self.mmd, "requires", + { 0 : 0 } ) + + def test_community_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "community", 0) + + def test_documentation_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "documentation", 0) + + def test_tracker_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "tracker", 0) + + def test_profiles_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "profiles", 0) + + def test_profiles_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd, "profiles", + { "key" : 0 } ) + self.assertRaises(TypeError, setattr, self.mmd, "profiles", + { 0 : ModuleProfile() } ) + self.assertRaises(TypeError, setattr, self.mmd, "profiles", + { 0 : 0 } ) + + def test_profile_description_type(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.assertRaises(TypeError, setattr, self.mmd.profiles["test"], + "description", 0) + + def test_profile_rpms_type(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.assertRaises(TypeError, setattr, self.mmd.profiles["test"], + "rpms", 0) + + def test_profile_rpms_type_deep(self): + self.mmd.profiles = { "test" : ModuleProfile() } + self.assertRaises(TypeError, setattr, self.mmd.profiles["test"], + "rpms", set([1, 2, 3])) + + def test_api_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "api", 0) + + def test_api_rpms_type(self): + self.assertRaises(TypeError, setattr, self.mmd.api, "rpms", 0) + + def test_api_rpms_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd.api, "rpms", + set([1, 2, 3])) + + def test_filter_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "filter", 0) + + def test_filter_rpms_type(self): + self.assertRaises(TypeError, setattr, self.mmd.filter, "rpms", 0) + + def test_filter_rpms_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd.filter, "rpms", + set([1, 2, 3])) + + def test_components_type(self): + self.assertRaises(TypeError, setattr, self.mmd, "components", 0) + + def test_components_rpms_type(self): + self.assertRaises(TypeError, setattr, self.mmd.components, "rpms", 0) + + def test_components_rpms_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd.components, "rpms", + { "key" : 0 } ) + self.assertRaises(TypeError, setattr, self.mmd.components, "rpms", + { 0 : ModuleComponentRPM("name", "rationale") } ) + self.assertRaises(TypeError, setattr, self.mmd.components, "rpms", + { 0 : 0 } ) + + def test_components_modules_type(self): + self.assertRaises(TypeError, setattr, self.mmd.components, "modules", 0) + + def test_components_modules_type_deep(self): + self.assertRaises(TypeError, setattr, self.mmd.components, "modules", + { "key" : 0 } ) + self.assertRaises(TypeError, setattr, self.mmd.components, "modules", + { 0 : ModuleComponentModule("name", "rationale") } ) + self.assertRaises(TypeError, setattr, self.mmd.components, "rpms", + { 0 : 0 } ) + + def test_component_base_name_type(self): + c = ModuleComponentBase("name", "rationale") + self.assertRaises(TypeError, setattr, c, "name", 0) + + def test_component_base_rationale_type(self): + c = ModuleComponentBase("name", "rationale") + self.assertRaises(TypeError, setattr, c, "rationale", 0) + + def test_component_base_buildorder_type(self): + c = ModuleComponentBase("name", "rationale") + self.assertRaises(TypeError, setattr, c, "buildorder", "") + + def test_component_rpm_name_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "name", 0) + + def test_component_rpm_rationale_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "rationale", 0) + + def test_component_rpm_buildorder_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "buildorder", "") + + def test_component_rpm_repository_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "repository", 0) + + def test_component_rpm_commit_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "commit", 0) + + def test_component_rpm_cache_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "cache", 0) + + def test_component_rpm_arches_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "arches", 0) + + def test_component_rpm_arches_type_deep(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "arches", set([1, 2, 3])) + + def test_component_rpm_multilib_type(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "multilib", 0) + + def test_component_rpm_multilib_type_deep(self): + c = ModuleComponentRPM("name", "rationale") + self.assertRaises(TypeError, setattr, c, "multilib", set([1, 2, 3])) + + def test_component_module_name_type(self): + c = ModuleComponentModule("name", "rationale") + self.assertRaises(TypeError, setattr, c, "name", 0) + + def test_component_module_rationale_type(self): + c = ModuleComponentModule("name", "rationale") + self.assertRaises(TypeError, setattr, c, "rationale", 0) + + def test_component_module_buildorder_type(self): + c = ModuleComponentModule("name", "rationale") + self.assertRaises(TypeError, setattr, c, "buildorder", "") + + def test_component_module_repository_type(self): + c = ModuleComponentModule("name", "rationale") + self.assertRaises(TypeError, setattr, c, "repository", 0) + + def test_component_module_commit_type(self): + c = ModuleComponentModule("name", "rationale") + self.assertRaises(TypeError, setattr, c, "commit", 0)