From 933595b22c6bb7e64a8ebd8098c47c81019cc80e Mon Sep 17 00:00:00 2001 From: Sybil Ehrensberger Date: Thu, 29 Sep 2016 17:52:41 +0200 Subject: [PATCH] Remove sorting for BOTS file --- intelmq/tests/test_conf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/intelmq/tests/test_conf.py b/intelmq/tests/test_conf.py index f62ec49a9..2d7615a71 100644 --- a/intelmq/tests/test_conf.py +++ b/intelmq/tests/test_conf.py @@ -5,6 +5,7 @@ import json import re import unittest +import collections import pkg_resources @@ -19,6 +20,14 @@ def to_json(obj): separators=(',', ': ')) + '\n' +def to_unsorted_json(obj): + """ + Transforms object into JSON with intelmq-style (without sorting). + """ + return json.dumps(obj, indent=4, sort_keys=False, + separators=(',', ': ')) + '\n' + + CONF_NAMES = ['defaults', 'harmonization', 'pipeline', 'runtime', 'startup', 'system'] @@ -90,8 +99,10 @@ def test_BOTS_syntax(self): with open(pkg_resources.resource_filename('intelmq', 'bots/BOTS')) as fhandle: fcontent = fhandle.read() - interpreted = json.loads(fcontent) - self.assertEqual(to_json(interpreted), fcontent) + + interpreted = json.loads(fcontent, + object_pairs_hook=collections.OrderedDict) + self.assertEqual(to_unsorted_json(interpreted), fcontent) if __name__ == '__main__':