2 Created on Jan 24, 2014
11 log = logging.getLogger('Comparator')
14 def compare_results(actual, expected):
15 #print 'ACT: ', actual
16 #print 'EXP: ', expected
18 list_unused = list(set(actual.keys()) - set(expected.keys()))
19 if len(list_unused) > 0:
20 Comparator.log.info('unchecked tags: {}'.format(list_unused))
22 list_duration = ['duration','hard_timeout','idle_timeout']
24 Comparator.test_duration(actual, expected)
26 # compare results from actual flow (mn dump result) and expepected flow (stored result)
27 for k in expected.keys():
28 if k not in list_duration:
29 assert k in actual, 'cannot find key {} in flow {}'.format(k, actual)
30 assert actual[k] == expected[k], 'key:{}, actual:{} != expected:{}'.format(k, actual[k], expected[k])
33 def test_duration(actual, expected):
34 duration_key = 'duration'
35 hard_to_key = 'hard_timeout'
37 if duration_key in expected.keys():
38 assert duration_key in actual.keys(), '{} is not set in {}'.format(duration_key, actual)
40 duration = float(expected['duration'].rstrip('s'))
41 hard_timeout = int(actual['hard_timeout'])
42 assert duration <= hard_timeout, 'duration is higher than hard_timeout, {} > {}'.format(duration, hard_timeout)
44 Comparator.log.warning('cannot find keys to test duration tag', exc_info=True)
46 # VD - what should we do in this case