@@ -156,3 +156,32 @@ def test_from_dict_ok(self, data_dict, expected_result):
156156 )
157157 def test_repr_ok (self , data , expected ):
158158 assert data .__repr__ () == expected
159+
160+ def test__eq__ (self ):
161+ a1 = ActionDomain (id = 1 , name = "action" )
162+ assert a1 == ActionDomain (id = 1 , name = "action" )
163+ assert a1 != ActionDomain (id = 2 , name = "action" )
164+ assert a1 != ActionDomain (id = 1 , name = "something" )
165+ assert a1 != SomeOtherDomain (id = 1 , name = "action" )
166+
167+ def test_nested__eq__ (self ):
168+ child1 = ActionDomain (id = 1 , name = "child" )
169+ d1 = SomeOtherDomain (id = 1 , name = "parent" , child = child1 )
170+ d2 = SomeOtherDomain (id = 1 , name = "parent" , child = child1 )
171+
172+ assert d1 == d2
173+
174+ d2 .child = ActionDomain (id = 2 , name = "child2" )
175+
176+ assert d1 != d2
177+
178+ def test_nested_list__eq__ (self ):
179+ child1 = ActionDomain (id = 1 , name = "child" )
180+ d1 = SomeOtherDomain (id = 1 , name = "parent" , child = [child1 ])
181+ d2 = SomeOtherDomain (id = 1 , name = "parent" , child = [child1 ])
182+
183+ assert d1 == d2
184+
185+ d2 .child = [ActionDomain (id = 2 , name = "child2" )]
186+
187+ assert d1 != d2
0 commit comments