def test_pick_attributes(self): dictionary = { 'level_one_1': { 'level_two_1': { 'level_three_1': 'level_three_1_value' }, 'level_two_2': 'level_two_2_value' }, 'level_one_2': 'level_one_2_value' } whitelisted_dictionary = pick_attributes(dictionary, [ '$.level_one_1.level_two_1.level_three_1', ['$', 'level_one_2'], '$.random.attribute' ]) expected_whitelisted_dictionary = { 'level_one_1': { 'level_two_1': { 'level_three_1': 'level_three_1_value' }, }, 'level_one_2': 'level_one_2_value' } self.assertEqual(expected_whitelisted_dictionary, whitelisted_dictionary)
def test_pick_attributes(self): dictionary = { "level_one_1": { "level_two_1": { "level_three_1": "level_three_1_value" }, "level_two_2": "level_two_2_value", }, "level_one_2": "level_one_2_value", } whitelisted_dictionary = pick_attributes( dictionary, [ "$.level_one_1.level_two_1.level_three_1", ["$", "level_one_2"], "$.random.attribute", ], ) expected_whitelisted_dictionary = { "level_one_1": { "level_two_1": { "level_three_1": "level_three_1_value" }, }, "level_one_2": "level_one_2_value", } self.assertEqual(expected_whitelisted_dictionary, whitelisted_dictionary)
def get_events_target_attributes(target): return dict_utils.pick_attributes(target, EVENT_TARGET_PARAMETERS)