@@ -1188,18 +1188,16 @@ async def test_schedule_create_limited_actions_validation(
11881188 assert "are remaining actions set" in str (err .value )
11891189
11901190
1191- async def test_schedule_search_attribute_update (
1191+ async def test_schedule_workflow_search_attribute_update (
11921192 client : Client , env : WorkflowEnvironment
11931193):
11941194 if env .supports_time_skipping :
11951195 pytest .skip ("Java test server doesn't support schedules" )
11961196 await assert_no_schedules (client )
11971197
11981198 # Put search attribute on server
1199- text_attr_key = SearchAttributeKey .for_text (f"python-test-schedule-text" )
1200- untyped_keyword_key = SearchAttributeKey .for_keyword (
1201- f"python-test-schedule-keyword"
1202- )
1199+ text_attr_key = SearchAttributeKey .for_text ("python-test-schedule-text" )
1200+ untyped_keyword_key = SearchAttributeKey .for_keyword ("python-test-schedule-keyword" )
12031201 await ensure_search_attributes_present (client , text_attr_key , untyped_keyword_key )
12041202
12051203 # Create a schedule with search attributes on the schedule and on the
@@ -1273,6 +1271,7 @@ def update_schedule_typed_attrs(
12731271 # Check that it changed
12741272 desc = await handle .describe ()
12751273 assert isinstance (desc .schedule .action , ScheduleActionStartWorkflow )
1274+ # Check that the workflow search attributes were changed
12761275 # This assertion has changed since server 1.24. Now, even untyped search
12771276 # attributes are given a type server side
12781277 assert (
@@ -1283,6 +1282,64 @@ def update_schedule_typed_attrs(
12831282 and desc .schedule .action .typed_search_attributes [untyped_keyword_key ]
12841283 == "some-untyped-attr1"
12851284 )
1285+ # Check that the schedule search attributes were not changed
1286+ assert desc .search_attributes [text_attr_key .name ] == ["some-schedule-attr1" ]
1287+ assert desc .typed_search_attributes [text_attr_key ] == "some-schedule-attr1"
1288+
1289+
1290+ async def test_schedule_search_attribute_update (
1291+ client : Client , env : WorkflowEnvironment
1292+ ):
1293+ if env .supports_time_skipping :
1294+ pytest .skip ("Java test server doesn't support schedules" )
1295+ await assert_no_schedules (client )
1296+
1297+ # Put search attribute on server
1298+ text_attr_key = SearchAttributeKey .for_text ("python-test-schedule-text" )
1299+ untyped_keyword_key = SearchAttributeKey .for_keyword ("python-test-schedule-keyword" )
1300+ await ensure_search_attributes_present (client , text_attr_key , untyped_keyword_key )
1301+
1302+ # Create a schedule with search attributes
1303+ create_action = ScheduleActionStartWorkflow (
1304+ "some workflow" ,
1305+ [],
1306+ id = f"workflow-{ uuid .uuid4 ()} " ,
1307+ task_queue = f"tq-{ uuid .uuid4 ()} " ,
1308+ )
1309+ handle = await client .create_schedule (
1310+ f"schedule-{ uuid .uuid4 ()} " ,
1311+ Schedule (action = create_action , spec = ScheduleSpec ()),
1312+ search_attributes = TypedSearchAttributes (
1313+ [SearchAttributePair (text_attr_key , "some-schedule-attr1" )]
1314+ ),
1315+ )
1316+
1317+ # Do update of search attributes
1318+ def update_schedule_search_attributes (
1319+ input : ScheduleUpdateInput ,
1320+ ) -> Optional [ScheduleUpdate ]:
1321+ # Make sure the search attributes are present in all forms
1322+ assert input .description .search_attributes [text_attr_key .name ] == [
1323+ "some-schedule-attr1"
1324+ ]
1325+ assert (
1326+ input .description .typed_search_attributes [text_attr_key ]
1327+ == "some-schedule-attr1"
1328+ )
1329+
1330+ return ScheduleUpdate (
1331+ input .description .schedule ,
1332+ search_attributes = input .description .typed_search_attributes .updated (
1333+ SearchAttributePair (text_attr_key , "some-schedule-attr2" )
1334+ ),
1335+ )
1336+
1337+ await handle .update (update_schedule_search_attributes )
1338+
1339+ # Check the changes
1340+ desc = await handle .describe ()
1341+ assert desc .typed_search_attributes [text_attr_key ] == "some-schedule-attr2"
1342+ assert desc .search_attributes [text_attr_key .name ] == ["some-schedule-attr2" ]
12861343
12871344
12881345async def assert_no_schedules (client : Client ) -> None :
0 commit comments