@@ -872,6 +872,27 @@ def test_style(self):
872872 "expected type Options for argument 'opts', but got int" ,
873873 )
874874
875+ opts = excelize .SheetProtectionOptions (
876+ select_locked_cells = True ,
877+ select_unlocked_cells = True ,
878+ edit_scenarios = True ,
879+ )
880+ self .assertIsNone (f .protect_sheet ("Sheet1" , opts ))
881+ result = f .get_sheet_protection ("Sheet1" )
882+ self .assertEqual (opts , result )
883+
884+ with self .assertRaises (RuntimeError ) as context :
885+ f .get_sheet_protection ("SheetN" )
886+ self .assertEqual (str (context .exception ), "sheet SheetN does not exist" )
887+ with self .assertRaises (TypeError ) as context :
888+ f .get_sheet_protection (1 )
889+ self .assertEqual (
890+ str (context .exception ),
891+ "expected type str for argument 'sheet', but got int" ,
892+ )
893+
894+ self .assertIsNone (f .unprotect_sheet ("Sheet1" ))
895+
875896 self .assertIsNone (
876897 f .protect_sheet (
877898 "Sheet1" ,
@@ -907,7 +928,6 @@ def test_style(self):
907928 "expected type str for argument 'password', but got int" ,
908929 )
909930 self .assertIsNone (f .unprotect_sheet ("Sheet1" , "password" ))
910- self .assertIsNone (f .unprotect_sheet ("Sheet1" ))
911931
912932 self .assertIsNone (
913933 f .protect_workbook (
@@ -1034,6 +1054,10 @@ def test_none_file_pointer(self):
10341054 with self .assertRaises (RuntimeError ) as context :
10351055 f .get_form_controls ("Sheet1" )
10361056 self .assertEqual (str (context .exception ), expected )
1057+ self .assertEqual (str (context .exception ), expected )
1058+ with self .assertRaises (RuntimeError ) as context :
1059+ f .get_hyperlink_cells ("Sheet1" , "" )
1060+ self .assertEqual (str (context .exception ), expected )
10371061 with self .assertRaises (RuntimeError ) as context :
10381062 f .get_page_layout ("Sheet1" )
10391063 self .assertEqual (str (context .exception ), expected )
@@ -1055,6 +1079,9 @@ def test_none_file_pointer(self):
10551079 str (context .exception ),
10561080 "expected type int for argument 'sheet', but got str" ,
10571081 )
1082+ with self .assertRaises (RuntimeError ) as context :
1083+ f .get_sheet_protection ("Sheet1" )
1084+ self .assertEqual (str (context .exception ), expected )
10581085 with self .assertRaises (RuntimeError ) as context :
10591086 f .get_workbook_props ()
10601087 self .assertEqual (str (context .exception ), expected )
@@ -2185,6 +2212,10 @@ def test_cell_hyperlink(self):
21852212 self .assertTrue (link )
21862213 self .assertEqual (target , display )
21872214
2215+ self .assertEqual (["A3" ], f .get_hyperlink_cells ("Sheet1" , "" ))
2216+ self .assertEqual ([], f .get_hyperlink_cells ("Sheet1" , "Location" ))
2217+ self .assertEqual ([], f .get_hyperlink_cells ("Sheet1" , "None" ))
2218+
21882219 with self .assertRaises (RuntimeError ) as context :
21892220 _ , _ = f .get_cell_hyperlink ("SheetN" , "A3" )
21902221 self .assertEqual (str (context .exception ), "sheet SheetN does not exist" )
@@ -2196,6 +2227,17 @@ def test_cell_hyperlink(self):
21962227 "expected type str for argument 'cell', but got int" ,
21972228 )
21982229
2230+ with self .assertRaises (RuntimeError ) as context :
2231+ f .get_hyperlink_cells ("SheetN" , "" )
2232+ self .assertEqual (str (context .exception ), "sheet SheetN does not exist" )
2233+
2234+ with self .assertRaises (TypeError ) as context :
2235+ f .get_hyperlink_cells ("Sheet1" , 1 )
2236+ self .assertEqual (
2237+ str (context .exception ),
2238+ "expected type str for argument 'link_type', but got int" ,
2239+ )
2240+
21992241 self .assertIsNone (f .save_as (os .path .join ("test" , "TestCellHyperLink.xlsx" )))
22002242 self .assertIsNone (f .close ())
22012243
0 commit comments