示例#1
0
    def test_filter_keys_recursive(self):
        test_obj = {'foo': 'bar', 'baz': 'qux', 'boo': {'foo': 'qux'}}

        utilities.filter_keys(['foo'], test_obj)

        self.assertEqual(test_obj['foo'], '<filtered>')
        self.assertEqual(test_obj['boo']['foo'], '<filtered>')
示例#2
0
    def test_filter_keys_with_wildcard(self):
        test_obj = {
            'foobr': 'bar',
            'foobz': 'baz',
            'fooqx': 'foo',
            'baz': 'qux'
        }

        utilities.filter_keys(['foo*'], test_obj)

        self.assertEqual(test_obj['foobr'], '<filtered>')
        self.assertEqual(test_obj['foobz'], '<filtered>')
        self.assertEqual(test_obj['fooqx'], '<filtered>')
    def test_filter_keys_filters_error(self):
        keys = ['identifier']
        self.sender.filter_keys(keys)

        self.sender.set_user({ 'identifier': 'foo' })

        self.assertEqual(utilities.filter_keys(keys, self.sender.user)['identifier'], '<filtered>')
    def test_filter_keys_filters_error(self):
        keys = ['identifier']
        self.sender.filter_keys(keys)

        self.sender.set_user({ 'identifier': 'foo' })

        self.assertEqual(utilities.filter_keys(keys, self.sender.user)['identifier'], '<filtered>')
示例#5
0
    def test_filter_keys_filters_error(self):
        keys = ["identifier"]
        self.sender.filter_keys(keys)

        self.sender.set_user({"identifier": "foo"})

        self.assertEqual(utilities.filter_keys(keys, self.sender.user)["identifier"], "<filtered>")
示例#6
0
    def _transform_message(self, message):
        message = utilities.ignore_exceptions(self.ignoredExceptions, message)

        if message is not None:
            message = utilities.filter_keys(self.filteredKeys, message)

        if self.beforeSendCallback is not None:
            mutated_payload = self.beforeSendCallback(message["details"])

            if mutated_payload is not None:
                message["details"] = mutated_payload
            else:
                return None

        return message
示例#7
0
    def _transform_message(self, message):
        message = utilities.ignore_exceptions(self.ignored_exceptions, message)

        if message is not None:
            message = utilities.filter_keys(self.filtered_keys, message)
            message['details']['groupingKey'] = utilities.execute_grouping_key(self.grouping_key_callback, message)

        if self.before_send_callback is not None:
            mutated_payload = self.before_send_callback(message['details'])

            if mutated_payload is not None:
                message['details'] = mutated_payload
            else:
                return None

        return message
示例#8
0
    def test_filter_keys(self):
        test_obj = {'foo': 'bar', 'baz': 'qux'}

        utilities.filter_keys(['foo'], test_obj)

        self.assertEqual(test_obj['foo'], '<filtered>')