@@ -23,7 +23,9 @@ def setUp(self):
2323 self .original_values = {}
2424 for key in UPGRADEABLE_KEYS :
2525 record_name = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } "
26- self .original_values [key ] = list (api .portal .get_registry_record (record_name ))
26+ self .original_values [key ] = list (
27+ api .portal .get_registry_record (record_name )
28+ )
2729 # Clear any existing upgrade annotations
2830 self ._clear_upgrade_annotations ()
2931
@@ -44,7 +46,9 @@ def _clear_upgrade_annotations(self):
4446 """Clear any upgrade annotations from the portal."""
4547 annotations = IAnnotations (self .portal )
4648 for key in UPGRADEABLE_KEYS :
47- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
49+ annotation_key = (
50+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
51+ )
4852 if annotation_key in annotations :
4953 del annotations [annotation_key ]
5054
@@ -61,7 +65,9 @@ def test_pre_handler_saves_values_to_annotations(self):
6165 # Check annotations were created
6266 annotations = IAnnotations (self .portal )
6367 for key in UPGRADEABLE_KEYS :
64- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
68+ annotation_key = (
69+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
70+ )
6571 self .assertIn (annotation_key , annotations )
6672 # Value should be a JSON string
6773 value_str = annotations [annotation_key ]
@@ -73,14 +79,17 @@ def test_pre_handler_saves_values_to_annotations(self):
7379 def test_post_handler_restores_values_from_annotations (self ):
7480 """Test that post_handler restores values from annotations.
7581
76- Note: pre_handler reads from old typo registry key 'dynamica_pages_control_panel'
77- which is typically empty. This test verifies the restore mechanism works
78- by manually setting up annotations.
82+ Note: pre_handler reads from old typo registry key
83+ 'dynamica_pages_control_panel' which is typically empty.
84+ This test verifies the restore mechanism works by manually
85+ setting up annotations.
7986 """
8087 # Manually set up annotations with known values
8188 annotations = IAnnotations (self .portal )
8289 for key in UPGRADEABLE_KEYS :
83- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
90+ annotation_key = (
91+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
92+ )
8493 # Store current values in annotations
8594 current_values = api .portal .get_registry_record (
8695 f"cs_dynamicpages.dynamic_pages_control_panel.{ key } " , default = []
@@ -105,23 +114,29 @@ def test_post_handler_removes_annotations(self):
105114 annotations = IAnnotations (self .portal )
106115 # Verify annotations exist
107116 for key in UPGRADEABLE_KEYS :
108- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
117+ annotation_key = (
118+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
119+ )
109120 self .assertIn (annotation_key , annotations )
110121
111122 # Run post_handler
112123 post_handler ()
113124
114125 # Verify annotations were removed
115126 for key in UPGRADEABLE_KEYS :
116- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
127+ annotation_key = (
128+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
129+ )
117130 self .assertNotIn (annotation_key , annotations )
118131
119132 def test_post_handler_handles_invalid_json (self ):
120133 """Test that post_handler handles invalid JSON gracefully."""
121134 # Manually set invalid JSON in annotations
122135 annotations = IAnnotations (self .portal )
123136 for key in UPGRADEABLE_KEYS :
124- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
137+ annotation_key = (
138+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
139+ )
125140 annotations [annotation_key ] = "invalid json {"
126141
127142 # Should not raise exception
@@ -139,7 +154,9 @@ def test_post_handler_handles_non_list_value(self):
139154 # Manually set a non-list JSON value
140155 annotations = IAnnotations (self .portal )
141156 for key in UPGRADEABLE_KEYS :
142- annotation_key = f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
157+ annotation_key = (
158+ f"cs_dynamicpages.dynamic_pages_control_panel.{ key } .UPGRADE"
159+ )
143160 annotations [annotation_key ] = json .dumps ({"not" : "a list" })
144161
145162 # Should not raise exception
0 commit comments