Skip to content

Commit

Permalink
Remove sorting for BOTS file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sybil Ehrensberger committed Sep 29, 2016
1 parent d5993d2 commit 933595b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions intelmq/tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import re
import unittest
import collections

import pkg_resources

Expand All @@ -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']

Expand Down Expand Up @@ -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__':
Expand Down

0 comments on commit 933595b

Please sign in to comment.