From fabb5a8cc20c56f2148f80788445b4a2b576c367 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Mon, 25 Jun 2018 21:41:32 +0200 Subject: [PATCH] make sure the order of exported rules and assigments is not random --- plone/app/contentrules/exportimport/rules.py | 8 ++++---- plone/app/contentrules/tests/test_configuration.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plone/app/contentrules/exportimport/rules.py b/plone/app/contentrules/exportimport/rules.py index 881ee94..821084d 100644 --- a/plone/app/contentrules/exportimport/rules.py +++ b/plone/app/contentrules/exportimport/rules.py @@ -116,7 +116,7 @@ def export_field(self, doc, field): if value is not None: if ICollection.providedBy(field): - for e in value: + for e in sorted(value): list_element = doc.createElement('element') list_element.appendChild(doc.createTextNode(str(e))) child.appendChild(list_element) @@ -317,7 +317,7 @@ def _extractRules(self): assignment_paths = set() - for name, rule in storage.items(): + for name, rule in sorted(storage.items()): rule_node = self._doc.createElement('rule') rule_node.setAttribute('name', name) @@ -367,7 +367,7 @@ def _extractRules(self): # are orderd properly site_path_length = len('/'.join(site.getPhysicalPath())) - for path in assignment_paths: + for path in sorted(assignment_paths): try: container = site.unrestrictedTraverse(path) except KeyError: @@ -378,7 +378,7 @@ def _extractRules(self): continue location = path[site_path_length:] - for name, assignment in assignable.items(): + for name, assignment in sorted(assignable.items()): assignment_node = self._doc.createElement('assignment') assignment_node.setAttribute('location', location) assignment_node.setAttribute('name', name) diff --git a/plone/app/contentrules/tests/test_configuration.py b/plone/app/contentrules/tests/test_configuration.py index 7eb65c6..c90e1a0 100644 --- a/plone/app/contentrules/tests/test_configuration.py +++ b/plone/app/contentrules/tests/test_configuration.py @@ -198,13 +198,13 @@ def testExport(self): - - - + + + """ - body = exporter.body - self.assertEqual(expected.strip(), body.strip().decode('utf8'), body.decode('utf8')) + body = exporter.body.decode('utf8') + self.assertEqual(expected.strip(), body.strip(), body)