@@ -845,6 +845,32 @@ def test_get_conditional_properties(self, dmge: DataModelGraphExplorer) -> None:
845845 # THEN the current node should have conditional properties
846846 assert gts .get_conditional_properties () == [("Diagnosis" , "Cancer" )]
847847
848+ def test_get_conditional_properties_multiple_watched_properties (
849+ self , dmge : DataModelGraphExplorer
850+ ) -> None :
851+ """Test GraphTraversalState.get_conditional_properties with multiple watched properties.
852+
853+ This test covers a bug where the 'value' variable was being mutated inside
854+ the inner loop when converting to display names.
855+
856+ """
857+ # GIVEN a GraphTraversalState instance where
858+ # - CancerType has a reverse dependency of FamilyHistory
859+ # - FamilyHistory is a valid value of MULTIPLE attributes
860+ gts = GraphTraversalState (dmge , "Patient" , logger = Mock ())
861+ gts ._nodes_to_process = ["CancerType" ]
862+
863+ # Use FamilyHistory because its display name ("Family History") differs from class label
864+ gts ._reverse_dependencies = {"CancerType" : ["FamilyHistory" ]}
865+ # FamilyHistory triggers multiple watched properties - this is key to triggering the bug
866+ gts ._valid_values_map = {"FamilyHistory" : ["Sex" , "YearofBirth" ]}
867+ # WHEN using move_to_next_node
868+ gts .move_to_next_node ()
869+ result = gts .get_conditional_properties ()
870+ assert len (result ) == 2
871+ assert ("Year of Birth" , "Family History" ) in result
872+ assert ("Sex" , "Family History" ) in result
873+
848874 def test_update_valid_values_map (self , dmge : DataModelGraphExplorer ) -> None :
849875 """Test GraphTraversalState._update_valid_values_map"""
850876 # GIVEN a GraphTraversalState instance
0 commit comments