Example #1
0
    def test_any_rule_pass(self):
        """Test that when set to `any`, if any rule passes that
        the item is returned."""
        operation = DictFilterOperation(
            config={
                'type':
                'any',
                'rules': [{
                    'type': 'equals',
                    'path': '$.level.deep.value',
                    'value': 'no way',
                }, {
                    'type': 'equals',
                    'path': '$.level.deep.value',
                    'value': 'hey',
                }]
            })

        self.assertEquals(
            operation.process(self.fake_dict),
            self.fake_dict,
        )
Example #2
0
    def test_all_rules_pass(self):
        """Test that when set to `all`, if all rules pass
        that the item is returned."""
        operation = DictFilterOperation(
            config={
                'type':
                'all',
                'rules': [{
                    'type': 'equals',
                    'path': '$.level.array[0].name',
                    'value': 'item1',
                }, {
                    'type': 'equals',
                    'path': '$.level.deep.value',
                    'value': 'hey',
                }]
            })

        self.assertEquals(
            operation.process(self.fake_dict),
            self.fake_dict,
        )