File tree 2 files changed +26
-0
lines changed 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,12 @@ class WriteAccessAllowed(TelegramObject):
28
28
This object represents a service message about a user allowing a bot to write messages after
29
29
adding the bot to the attachment menu or launching a Web App from a link.
30
30
31
+ Objects of this class are comparable in terms of equality. Two objects of this class are
32
+ considered equal, if their :attr:`web_app_name` is equal.
33
+
31
34
.. versionadded:: 20.0
35
+ .. versionchanged:: NEXT.VERSION
36
+ Added custom equality comparison for objects of this class.
32
37
33
38
Args:
34
39
web_app_name (:obj:`str`, optional): Name of the Web App which was launched from a link.
@@ -50,4 +55,6 @@ def __init__(
50
55
super ().__init__ (api_kwargs = api_kwargs )
51
56
self .web_app_name : Optional [str ] = web_app_name
52
57
58
+ self ._id_attrs = (self .web_app_name ,)
59
+
53
60
self ._freeze ()
Original file line number Diff line number Diff line change @@ -36,3 +36,22 @@ def test_to_dict(self):
36
36
action = WriteAccessAllowed ()
37
37
action_dict = action .to_dict ()
38
38
assert action_dict == {}
39
+
40
+ def test_equality (self ):
41
+ a = WriteAccessAllowed ()
42
+ b = WriteAccessAllowed ()
43
+ c = WriteAccessAllowed (web_app_name = "foo" )
44
+ d = WriteAccessAllowed (web_app_name = "foo" )
45
+ e = WriteAccessAllowed (web_app_name = "bar" )
46
+
47
+ assert a == b
48
+ assert hash (a ) == hash (b )
49
+
50
+ assert a != c
51
+ assert hash (a ) != hash (c )
52
+
53
+ assert c == d
54
+ assert hash (c ) == hash (d )
55
+
56
+ assert c != e
57
+ assert hash (c ) != hash (e )
You can’t perform that action at this time.
0 commit comments