File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-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,15 @@ 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+ assert bound_model_a == bound_model_b
90+ bound_model_b .data_model .name = "changed_name"
91+ assert bound_model_a != bound_model_b
92+
8493
8594class TestClientEntityBase :
8695 @pytest .fixture ()
You can’t perform that action at this time.
0 commit comments