Beispiel #1
0
 def test_join_predicates(self):
     a_predicate = {
         'type': 'not your business',
         'format': 'as you like'
     }
     same_predicate = {
         'type': 'who knows',
         'format': 'who cares'
     }
     expected = {
         'type': 'array',
         'range': [
             {'type': 'not your business', 'format': 'as you like'},
             {'type': 'who knows', 'format': 'who cares'}
         ]
     }
     computed = join_predicates(a_predicate, same_predicate)
     self.assertEqual(computed['type'], expected['type'])
     self.assertFalse('format' in expected)
     self.assertEqual(sortListDict(computed['range']), sortListDict(expected['range']))
Beispiel #2
0
 def test_merge_ranges_deals_with_duplicates(self):
     r1 = {'r1': 1}
     r2 = {'r1': 1}
     expected = [{'r1': 1}]
     computed = merge_ranges(r1, r2)
     self.assertEqual(sortListDict(computed), sortListDict(expected))
Beispiel #3
0
 def _test_merge_ranges_first_is_not_list(self):
     r1 = {'r1': 1}
     r2 = [{'r2': 2}, {'r3': 3}]
     expected = [{'r2': 2}, {'r3': 3}, {'r1': 1}]
     computed = merge_ranges(r1, r2)
     self.assertEqual(sortListDict(computed), sortListDict(expected))
Beispiel #4
0
 def _test_merge_ranges_both_are_lists(self):
     r1 = [{'r0': 0}, {'r1': 1}]
     r2 = [{'r2': 2}, {'r3': 3}]
     expected = [{'r0': 0}, {'r1': 1}, {'r2': 2}, {'r3': 3}]
     computed = merge_ranges(r1, r2)
     self.assertEqual(sortListDict(computed), sortListDict(expected))
Beispiel #5
0
 def _test_merge_ranges_both_arent_lists(self):
     r1 = {'r1': 1}
     r2 = {'r2': 2}
     expected = [{'r1': 1}, {'r2': 2}]
     computed = merge_ranges(r1, r2)
     self.assertEqual(sortListDict(computed), sortListDict(expected))