File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ def get_operation(self, op_id):
3434 return self .operations [op_id ]
3535
3636 def remove_operation (self , op_id ):
37- del self .operations [op_id ]
37+ try :
38+ del self .operations [op_id ]
39+ except KeyError :
40+ pass
3841
3942 def receive (self ):
4043 raise NotImplementedError ("receive method not implemented" )
Original file line number Diff line number Diff line change @@ -60,3 +60,15 @@ def test_message_invalid():
6060 server .send_error = mock .Mock ()
6161 server .on_message (connection_context = None , message = "'not-json" )
6262 assert server .send_error .called
63+
64+
65+ def test_context_operations ():
66+ ws = mock .Mock ()
67+ context = base .BaseConnectionContext (ws )
68+ assert not context .has_operation (1 )
69+ context .register_operation (1 , None )
70+ assert context .has_operation (1 )
71+ context .remove_operation (1 )
72+ assert not context .has_operation (1 )
73+ # Removing a non-existant operation fails silently.
74+ context .remove_operation (999 )
You can’t perform that action at this time.
0 commit comments