@@ -3322,31 +3322,27 @@ def test_modify_visibility(self):
33223322 if field_name not in schema :
33233323 self .sg .schema_field_create ("Asset" , "text" , "Project Visibility Test" )
33243324
3325- # Grab any two projects that we can use for toggling the visible property with.
3326- projects = self .sg .find (
3327- "Project" , [], order = [{"field_name" : "id" , "direction" : "asc" }]
3328- )
3329- project_1 = projects [0 ]
3330- project_2 = projects [1 ]
3331-
3332- def assert_visibility (project , expected , retries = 5 , delay = 1 ):
3333- """Poll until schema_field_read reflects the expected visibility value."""
3334- result = None
3335- for _ in range (retries ):
3336- result = self .sg .schema_field_read ("Asset" , field_name , project )[
3337- field_name
3338- ]["visible" ]
3339- if result == expected :
3340- return
3341- time .sleep (delay )
3342- self .assertEqual (expected , result )
3325+ # Hide/show on the ephemeral CI project so concurrent matrix jobs do not race.
3326+ # Use the oldest site project as the control.
3327+ project_1 = self .project
3328+ project_2 = self .sg .find_one ("Project" , [])
33433329
33443330 # First, reset the field visibility in a known state, i.e. visible for both projects,
33453331 # in case the last test run failed midway through.
33463332 self .sg .schema_field_update ("Asset" , field_name , {"visible" : True }, project_1 )
3347- assert_visibility (project_1 , {"value" : True , "editable" : True })
3333+ self .assertEqual (
3334+ {"value" : True , "editable" : True },
3335+ self .sg .schema_field_read ("Asset" , field_name , project_1 )[field_name ][
3336+ "visible"
3337+ ],
3338+ )
33483339 self .sg .schema_field_update ("Asset" , field_name , {"visible" : True }, project_2 )
3349- assert_visibility (project_2 , {"value" : True , "editable" : True })
3340+ self .assertEqual (
3341+ {"value" : True , "editable" : True },
3342+ self .sg .schema_field_read ("Asset" , field_name , project_2 )[field_name ][
3343+ "visible"
3344+ ],
3345+ )
33503346
33513347 # Built-in fields should remain not editable.
33523348 self .assertFalse (
@@ -3362,7 +3358,12 @@ def assert_visibility(project, expected, retries=5, delay=1):
33623358 # Hide the field on project 1
33633359 self .sg .schema_field_update ("Asset" , field_name , {"visible" : False }, project_1 )
33643360 # It should not be visible anymore.
3365- assert_visibility (project_1 , {"value" : False , "editable" : True })
3361+ self .assertEqual (
3362+ {"value" : False , "editable" : True },
3363+ self .sg .schema_field_read ("Asset" , field_name , project_1 )[field_name ][
3364+ "visible"
3365+ ],
3366+ )
33663367
33673368 # The field should be visible on the second project.
33683369 self .assertEqual (
@@ -3374,7 +3375,12 @@ def assert_visibility(project, expected, retries=5, delay=1):
33743375
33753376 # Restore the visibility on the field.
33763377 self .sg .schema_field_update ("Asset" , field_name , {"visible" : True }, project_1 )
3377- assert_visibility (project_1 , {"value" : True , "editable" : True })
3378+ self .assertEqual (
3379+ {"value" : True , "editable" : True },
3380+ self .sg .schema_field_read ("Asset" , field_name , project_1 )[field_name ][
3381+ "visible"
3382+ ],
3383+ )
33783384
33793385
33803386class TestLibImports (base .LiveTestBase ):
0 commit comments