@@ -854,11 +854,17 @@ async def test_set_storage_location_creates_new_custom_storage_location(
854854 """Test that when there is no existing project setting and we set a storage location, a new project setting is created."""
855855 folder = Folder (id = SYN_123 )
856856
857- with patch .object (
858- ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
859- ), patch .object (
860- ProjectSetting , "store_async" , autospec = True , return_value = example_setting
861- ) as mocked_store :
857+ with (
858+ patch .object (
859+ ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
860+ ),
861+ patch .object (
862+ ProjectSetting ,
863+ "store_async" ,
864+ autospec = True ,
865+ return_value = example_setting ,
866+ ) as mocked_store ,
867+ ):
862868 result = await folder .set_storage_location_async (
863869 storage_location_id = self .STORAGE_LOCATION_ID ,
864870 synapse_client = self .syn ,
@@ -883,14 +889,20 @@ async def test_set_storage_location_updates_existing_setting(
883889 locations = [99999 ],
884890 )
885891
886- with patch .object (
887- ProjectSetting ,
888- "get_async" ,
889- new_callable = AsyncMock ,
890- return_value = example_setting ,
891- ), patch .object (
892- ProjectSetting , "store_async" , autospec = True , return_value = updated_setting
893- ) as mocked_store :
892+ with (
893+ patch .object (
894+ ProjectSetting ,
895+ "get_async" ,
896+ new_callable = AsyncMock ,
897+ return_value = example_setting ,
898+ ),
899+ patch .object (
900+ ProjectSetting ,
901+ "store_async" ,
902+ autospec = True ,
903+ return_value = updated_setting ,
904+ ) as mocked_store ,
905+ ):
894906 result = await folder .set_storage_location_async (
895907 storage_location_id = 99999 ,
896908 synapse_client = self .syn ,
@@ -919,16 +931,19 @@ async def test_set_storage_location_replaces_all_existing_locations(self) -> Non
919931 locations = [333 ],
920932 )
921933
922- with patch .object (
923- ProjectSetting ,
924- "get_async" ,
925- new_callable = AsyncMock ,
926- return_value = existing_setting ,
927- ), patch .object (
928- ProjectSetting ,
929- "store_async" ,
930- new_callable = AsyncMock ,
931- return_value = updated_setting ,
934+ with (
935+ patch .object (
936+ ProjectSetting ,
937+ "get_async" ,
938+ new_callable = AsyncMock ,
939+ return_value = existing_setting ,
940+ ),
941+ patch .object (
942+ ProjectSetting ,
943+ "store_async" ,
944+ new_callable = AsyncMock ,
945+ return_value = updated_setting ,
946+ ),
932947 ):
933948 result = await folder .set_storage_location_async (
934949 storage_location_id = 333 ,
@@ -955,14 +970,20 @@ async def test_set_storage_location_use_default_storage_location_instead(
955970 locations = [DEFAULT_STORAGE_LOCATION_ID ],
956971 )
957972
958- with patch .object (
959- ProjectSetting ,
960- "get_async" ,
961- new_callable = AsyncMock ,
962- return_value = example_setting ,
963- ), patch .object (
964- ProjectSetting , "store_async" , autospec = True , return_value = default_setting
965- ) as mocked_store :
973+ with (
974+ patch .object (
975+ ProjectSetting ,
976+ "get_async" ,
977+ new_callable = AsyncMock ,
978+ return_value = example_setting ,
979+ ),
980+ patch .object (
981+ ProjectSetting ,
982+ "store_async" ,
983+ autospec = True ,
984+ return_value = default_setting ,
985+ ) as mocked_store ,
986+ ):
966987 result = await folder .set_storage_location_async (
967988 synapse_client = self .syn ,
968989 )
@@ -988,14 +1009,20 @@ async def test_set_storage_location_uses_default_storage_location_instead_when_s
9881009 locations = [DEFAULT_STORAGE_LOCATION_ID ],
9891010 )
9901011
991- with patch .object (
992- ProjectSetting ,
993- "get_async" ,
994- new_callable = AsyncMock ,
995- return_value = example_setting ,
996- ), patch .object (
997- ProjectSetting , "store_async" , autospec = True , return_value = default_setting
998- ) as mocked_store :
1012+ with (
1013+ patch .object (
1014+ ProjectSetting ,
1015+ "get_async" ,
1016+ new_callable = AsyncMock ,
1017+ return_value = example_setting ,
1018+ ),
1019+ patch .object (
1020+ ProjectSetting ,
1021+ "store_async" ,
1022+ autospec = True ,
1023+ return_value = default_setting ,
1024+ ) as mocked_store ,
1025+ ):
9991026 result = await folder .set_storage_location_async (
10001027 storage_location_id = None ,
10011028 synapse_client = self .syn ,
@@ -1011,11 +1038,17 @@ async def test_set_storage_location_accepts_list_of_ids(
10111038 """Test that when storage_location_id is a list of integers, all are stored as-is."""
10121039 folder = Folder (id = SYN_123 )
10131040
1014- with patch .object (
1015- ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
1016- ), patch .object (
1017- ProjectSetting , "store_async" , autospec = True , return_value = example_setting
1018- ) as mocked_store :
1041+ with (
1042+ patch .object (
1043+ ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
1044+ ),
1045+ patch .object (
1046+ ProjectSetting ,
1047+ "store_async" ,
1048+ autospec = True ,
1049+ return_value = example_setting ,
1050+ ) as mocked_store ,
1051+ ):
10191052 await folder .set_storage_location_async (
10201053 storage_location_id = [111 , 222 , 333 ],
10211054 synapse_client = self .syn ,
@@ -1030,11 +1063,17 @@ async def test_set_storage_location_converts_single_id_to_list(
10301063 """Test that when storage_location_id is a single integer, it is wrapped in a list."""
10311064 folder = Folder (id = SYN_123 )
10321065
1033- with patch .object (
1034- ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
1035- ), patch .object (
1036- ProjectSetting , "store_async" , autospec = True , return_value = example_setting
1037- ) as mocked_store :
1066+ with (
1067+ patch .object (
1068+ ProjectSetting , "get_async" , new_callable = AsyncMock , return_value = None
1069+ ),
1070+ patch .object (
1071+ ProjectSetting ,
1072+ "store_async" ,
1073+ autospec = True ,
1074+ return_value = example_setting ,
1075+ ) as mocked_store ,
1076+ ):
10381077 await folder .set_storage_location_async (
10391078 storage_location_id = 111 ,
10401079 synapse_client = self .syn ,
@@ -1061,17 +1100,20 @@ async def test_partial_update_locations_via_get_and_store(self) -> None:
10611100 locations = [111 , 222 , 333 ],
10621101 )
10631102
1064- with patch .object (
1065- ProjectSetting ,
1066- "get_async" ,
1067- new_callable = AsyncMock ,
1068- return_value = existing_setting ,
1069- ), patch .object (
1070- ProjectSetting ,
1071- "store_async" ,
1072- new_callable = AsyncMock ,
1073- return_value = updated_setting ,
1074- ) as mocked_store :
1103+ with (
1104+ patch .object (
1105+ ProjectSetting ,
1106+ "get_async" ,
1107+ new_callable = AsyncMock ,
1108+ return_value = existing_setting ,
1109+ ),
1110+ patch .object (
1111+ ProjectSetting ,
1112+ "store_async" ,
1113+ new_callable = AsyncMock ,
1114+ return_value = updated_setting ,
1115+ ) as mocked_store ,
1116+ ):
10751117 setting = await folder .get_project_setting_async (
10761118 setting_type = "upload" ,
10771119 synapse_client = self .syn ,
0 commit comments