File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -96,3 +96,9 @@ def __repr__(self) -> str:
9696 # models, as they will generate a lot of API call trying to print all the fields
9797 # of the model.
9898 return object .__repr__ (self )
99+
100+ def __eq__ (self , other : Any ) -> bool :
101+ """Compare a bound model object with another of the same type."""
102+ if not isinstance (other , self .__class__ ):
103+ return NotImplemented
104+ return self .data_model == other .data_model
Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ def test_get_non_exists_model_attribute_incomplete_model(
8181 client .get_by_id .assert_not_called ()
8282 assert bound_model .complete is False
8383
84+ def test_equality (self , bound_model_class , client ):
85+ data = {"id" : 1 , "name" : "name" , "description" : "my_description" }
86+ bound_model_a = bound_model_class (client = client , data = data )
87+ bound_model_b = bound_model_class (client = client , data = data )
88+
89+ # Comparing a bound model with a base domain
90+ assert bound_model_a == bound_model_a .data_model
91+
92+ # Identical bound models
93+ assert bound_model_a == bound_model_b
94+ assert bound_model_a == bound_model_b .data_model
95+
96+ # Differing bound models
97+ bound_model_b .data_model .name = "changed_name"
98+ assert bound_model_a != bound_model_b
99+ assert bound_model_a != bound_model_b .data_model
100+
84101
85102class TestClientEntityBase :
86103 @pytest .fixture ()
You can’t perform that action at this time.
0 commit comments