summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2015-01-03 13:07:14 -0600
committerSol Jerome <sol.jerome@gmail.com>2015-01-03 13:07:14 -0600
commit99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692 (patch)
tree852aa12fe61fb9559f3888fed7b1bf234de6b9e9 /testsuite
parent128efd62c9acf84c54f071043e1ea954da3361dd (diff)
parentd4ae5e04739d9a8e0732dd35ee28c14b0ff96957 (diff)
downloadbcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.tar.gz
bcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.tar.bz2
bcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.zip
Merge branch 'bundle-modification-deps' of https://github.com/AlexanderS/bcfg2
Conflicts: src/lib/Bcfg2/Client/__init__.py
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestBundler.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestBundler.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestBundler.py
index cfb379c40..1bf208c3e 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestBundler.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestBundler.py
@@ -3,6 +3,7 @@ import sys
import lxml.etree
from mock import Mock, MagicMock, patch
from Bcfg2.Server.Plugins.Bundler import *
+from Bcfg2.version import Bcfg2VersionInfo
# add all parent testsuite directories to sys.path to allow (most)
# relative imports in python 2.4
@@ -74,11 +75,15 @@ class TestBundler(TestPlugin, TestStructure, TestXMLDirectoryBacked):
lxml.etree.SubElement(expected['xinclude'], "Path", name="/test")
has_dep = lxml.etree.Element("Bundle")
- lxml.etree.SubElement(has_dep, "Bundle", name="is_dep")
+ lxml.etree.SubElement(has_dep, "RequiredBundle", name="is_dep")
+ lxml.etree.SubElement(has_dep, "RequiredBundle", name="is_mod_dep",
+ inherit_modification="true")
lxml.etree.SubElement(has_dep, "Package", name="foo")
b.bundles['has_dep'].XMLMatch.return_value = has_dep
expected['has_dep'] = lxml.etree.Element("Bundle", name="has_dep")
lxml.etree.SubElement(expected['has_dep'], "Package", name="foo")
+ lxml.etree.SubElement(expected['has_dep'], "Bundle",
+ name="is_mod_dep")
is_dep = lxml.etree.Element("Bundle")
lxml.etree.SubElement(is_dep, "Package", name="bar")
@@ -94,6 +99,7 @@ class TestBundler(TestPlugin, TestStructure, TestXMLDirectoryBacked):
metadata = Mock()
metadata.bundles = ["error", "xinclude", "has_dep", "indep"]
+ metadata.version_info = Bcfg2VersionInfo('1.4.0')
rv = b.BuildStructures(metadata)
self.assertEqual(len(rv), 4)
@@ -109,3 +115,33 @@ class TestBundler(TestPlugin, TestStructure, TestXMLDirectoryBacked):
b.bundles['error'].XMLMatch.assert_called_with(metadata)
self.assertFalse(b.bundles['skip'].XMLMatch.called)
+
+ def test_BuildStructuresOldClient(self):
+ b = self.get_obj()
+ b.bundles = dict(has_dep=Mock())
+ expected = dict()
+
+ has_dep = lxml.etree.Element("Bundle")
+ lxml.etree.SubElement(has_dep, "RequiredBundle", name="is_dep")
+ lxml.etree.SubElement(has_dep, "RequiredBundle", name="is_mod_dep",
+ inherit_modification="true")
+ lxml.etree.SubElement(has_dep, "Package", name="foo")
+ b.bundles['has_dep'].XMLMatch.return_value = has_dep
+ expected['has_dep'] = lxml.etree.Element("Bundle", name="has_dep")
+ lxml.etree.SubElement(expected['has_dep'], "Package", name="foo")
+
+ metadata = Mock()
+ metadata.bundles = ["has_dep"]
+ metadata.version_info = Bcfg2VersionInfo('1.3.0')
+
+ rv = b.BuildStructures(metadata)
+ self.assertEqual(len(rv), len(metadata.bundles))
+ for bundle in rv:
+ name = bundle.get("name")
+ self.assertIsNotNone(name,
+ "Bundle %s was not built" % name)
+ self.assertIn(name, expected,
+ "Unexpected bundle %s was built" % name)
+ self.assertXMLEqual(bundle, expected[name],
+ "Bundle %s was not built correctly" % name)
+ b.bundles[name].XMLMatch.assert_called_with(metadata)