Exemplo n.º 1
0
    def test_filter_star(self):
        doc = {'ttl': 300, 'body': {'event': 'start_backup'}}

        spec = [('body', '*', None), ('ttl', '*', None)]
        filtered = utils.filter(doc, spec)

        self.assertEqual(doc, filtered)
Exemplo n.º 2
0
    def test_filter_star(self):
        doc = {"ttl": 300, "body": {"event": "start_backup"}}

        spec = [("body", "*", None), ("ttl", "*", None)]
        filtered = utils.filter(doc, spec)

        self.assertEqual(doc, filtered)
Exemplo n.º 3
0
    def test_filter_star(self):
        doc = {'ttl': 300, 'body': {'event': 'start_backup'}}

        spec = [('body', '*', None), ('ttl', '*', None)]
        filtered = utils.filter(doc, spec)

        self.assertEqual(filtered, doc)
Exemplo n.º 4
0
    def test_filter_missing(self):
        doc = {"body": {"event": "start_backup"}}
        spec = (("tag", dict, None),)
        self.assertRaises(falcon.HTTPBadRequest, utils.filter, doc, spec)

        spec = (("tag", str, "db"),)
        filtered = utils.filter(doc, spec)
        self.assertEqual({"tag": "db"}, filtered)
Exemplo n.º 5
0
    def test_filter_missing(self):
        doc = {'body': {'event': 'start_backup'}}
        spec = (('tag', dict, None), )
        self.assertRaises(falcon.HTTPBadRequest, utils.filter, doc, spec)

        spec = (('tag', str, 'db'), )
        filtered = utils.filter(doc, spec)
        self.assertEqual(filtered, {'tag': 'db'})
Exemplo n.º 6
0
    def test_filter(self):
        doc = {'body': {'event': 'start_backup'}}

        def spec():
            yield ('body', dict, None)

        filtered = utils.filter(doc, spec())
        self.assertEqual(doc, filtered)

        doc = {'ttl': 300, 'bogus': 'yogabbagabba'}
        spec = [('ttl', int, None)]
        filtered = utils.filter(doc, spec)
        self.assertEqual({'ttl': 300}, filtered)

        doc = {'body': {'event': 'start_backup'}, 'ttl': 300}
        spec = (('body', dict, None), ('ttl', int, None))
        filtered = utils.filter(doc, spec)
        self.assertEqual(doc, filtered)
Exemplo n.º 7
0
    def test_filter(self):
        doc = {"body": {"event": "start_backup"}}

        def spec():
            yield ("body", dict, None)

        filtered = utils.filter(doc, spec())
        self.assertEqual(doc, filtered)

        doc = {"ttl": 300, "bogus": "yogabbagabba"}
        spec = [("ttl", int, None)]
        filtered = utils.filter(doc, spec)
        self.assertEqual({"ttl": 300}, filtered)

        doc = {"body": {"event": "start_backup"}, "ttl": 300}
        spec = (("body", dict, None), ("ttl", int, None))
        filtered = utils.filter(doc, spec)
        self.assertEqual(doc, filtered)
Exemplo n.º 8
0
    def test_filter(self):
        doc = {'body': {'event': 'start_backup'}}

        def spec():
            yield ('body', dict, None)

        filtered = utils.filter(doc, spec())
        self.assertEqual(filtered, doc)

        doc = {'ttl': 300, 'bogus': 'yogabbagabba'}
        spec = [('ttl', int, None)]
        filtered = utils.filter(doc, spec)
        self.assertEqual(filtered, {'ttl': 300})

        doc = {'body': {'event': 'start_backup'}, 'ttl': 300}
        spec = (('body', dict, None), ('ttl', int, None))
        filtered = utils.filter(doc, spec)
        self.assertEqual(filtered, doc)
Exemplo n.º 9
0
    def test_filter_missing(self):
        doc = {'body': {'event': 'start_backup'}}
        spec = (('tag', dict, None),)
        self.assertRaises(falcon.HTTPBadRequest,
                          utils.filter, doc, spec)

        spec = (('tag', str, 'db'),)
        filtered = utils.filter(doc, spec)
        self.assertEqual(filtered, {'tag': 'db'})