visitor pattern self visitor compositevisitor(truefalseself my_home_system accept(self visitorretrieved_state sorted([str( statusfor in self my_home_system iterable]self assertequal(retrieved_statesorted(expected_state)def test_person_ _not_home_person_ _home(self)expected_state mapstrself my_home_system iterable[ status'cooling' " : self visitor compositevisitor(falsetrueself my_home_system accept(self visitorretrieved_state sorted([str( statusfor in self my_home_system iterable]self assertequal(retrieved_statesorted(expected_state)def test_person_ _home_person_ _home(self)expected_state mapstrself my_home_system iterable[ status'on' self my_home_system iterable[ status