Guest User

Untitled

a guest
Jan 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. class DummyClient(object):
  2.     def __init__(self):
  3.         self.d = Deferred()
  4.  
  5.     def resultRender(self, r):
  6.         self.d.callback(r)
  7.  
  8.  
  9. # Metod from test
  10.  
  11.     def test_client_ref(self):
  12.         """
  13.        Test that when Command is init'ed with a Client protocol instance ref
  14.        it executes the ref's resultRender when Command.recv_result is executed
  15.        """
  16.         self.client_called = False
  17.  
  18.         def client_got_called(result):
  19.             self.client_called = True
  20.  
  21.         client = DummyClient()
  22.         client.d.addCallback(client_got_called)
  23.  
  24.         command = cmd.Command("test", content_type="plain",
  25.                             client=client)
  26.         command.recv_result("test")
  27.  
  28.         def cb(test):
  29.             self.assertIsInstance(test, dict)
  30.         command._d.addCallback(cb)
  31.         command.success()
Add Comment
Please, Sign In to add comment