From e46e8e1983f9ee1c308e19f26acddfec17b6fda1 Mon Sep 17 00:00:00 2001 From: Pawel Date: Wed, 17 Apr 2024 00:42:53 -0700 Subject: [PATCH] added test for multi level shortening --- rollbar/test/test_shortener_transform.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rollbar/test/test_shortener_transform.py b/rollbar/test/test_shortener_transform.py index b1c3f796..3dfe47d6 100644 --- a/rollbar/test/test_shortener_transform.py +++ b/rollbar/test/test_shortener_transform.py @@ -39,7 +39,8 @@ def setUp(self): 'deque': deque([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 15), 'other': TestClassWithAVeryVeryVeryVeryVeryVeryVeryLongName(), 'list_max_level': [1, [2, [3, [4, ["good_5", ["bad_6", ["bad_7"]]]]]]], - 'dict_max_level': {1: 1, 2: {3: {4: {"level4": "good", "level5": {"toplevel": "ok", 6: {7: {}}}}}}} + 'dict_max_level': {1: 1, 2: {3: {4: {"level4": "good", "level5": {"toplevel": "ok", 6: {7: {}}}}}}}, + 'list_multi_level': [1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]] } def _assert_shortened(self, key, expected): @@ -48,7 +49,7 @@ def _assert_shortened(self, key, expected): if key == 'dict': self.assertEqual(expected, len(result[key])) - elif key in ('list_max_level', 'dict_max_level'): + elif key in ('list_max_level', 'dict_max_level', 'list_multi_level'): self.assertEqual(expected, result[key]) else: # the repr output can vary between Python versions @@ -56,7 +57,7 @@ def _assert_shortened(self, key, expected): if key == 'other': self.assertIn(expected, stripped_result_key) - elif key not in ('dict', 'list_max_level', 'dict_max_level'): + elif key not in ('dict', 'list_max_level', 'dict_max_level', 'list_multi_level'): self.assertEqual(expected, stripped_result_key) # make sure nothing else was shortened @@ -90,6 +91,10 @@ def test_shorten_list_max_level(self): expected = [1, [2, [3, [4, ['good_5']]]]] self._assert_shortened('list_max_level', expected) + def test_shorten_list_multi_level(self): + expected = [1, '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]'] + self._assert_shortened('list_multi_level', expected) + def test_shorten_dict_max_level(self): expected = {1: 1, 2: {3: {4: {'level4': 'good', 'level5': {'toplevel': 'ok'}}}}} self._assert_shortened('dict_max_level', expected)