def test_filter_star(self): doc = {'ttl': 300, 'body': {'event': 'start_backup'}} spec = [('body', '*'), ('ttl', '*')] filtered = utils.filter(doc, spec) self.assertEqual(filtered, doc)
def test_filter(self): doc = {'body': {'event': 'start_backup'}} def spec(): yield ('body', dict) filtered = utils.filter(doc, spec()) self.assertEqual(filtered, doc) doc = {'ttl': 300, 'bogus': 'yogabbagabba'} spec = [('ttl', int)] filtered = utils.filter(doc, spec) self.assertEqual(filtered, {'ttl': 300}) doc = {'body': {'event': 'start_backup'}, 'ttl': 300} spec = (('body', dict), ('ttl', int)) filtered = utils.filter(doc, spec) self.assertEqual(filtered, doc)