コード例 #1
0
 def test_update_registration_simple(self):
     listener = msgpack.Listener(self.master)
     reg = yield listener.updateRegistration('example', 'pass', 'tcp:1234')
     self.assertEqual(self.master.msgmanager._registrations,
                      [('tcp:1234', 'example', 'pass')])
     self.assertEqual(listener._registrations['example'],
                      ('pass', 'tcp:1234', reg))
コード例 #2
0
 def test_update_registration_port_changed(self):
     listener = msgpack.Listener(self.master)
     listener.updateRegistration('example', 'pass', 'tcp:1234')
     reg1 = yield listener.updateRegistration('example', 'pass', 'tcp:4321')
     self.assertEqual(listener._registrations['example'],
                      ('pass', 'tcp:4321', reg1))
     self.assertEqual(self.master.msgmanager._unregistrations,
                      [('tcp:1234', 'example')])
コード例 #3
0
    def __init__(self, master):
        super().__init__()

        self.pb = bbpb.Listener(master)
        self.msgpack = bbmsgpack.Listener(master)

        # WorkerRegistration instances keyed by worker name
        self.registrations = {}

        # connection objects keyed by worker name
        self.connections = {}
コード例 #4
0
    def test_create_connection(self):
        listener = msgpack.Listener(self.master)
        listener.before_connection_setup = mock.Mock()
        worker = mock.Mock()
        worker.workername = 'test'
        protocol = mock.Mock()

        listener.updateRegistration('example', 'pass', 'tcp:1234')
        self.master.workers.register(worker)
        conn = yield listener._create_connection(protocol, worker.workername)

        listener.before_connection_setup.assert_called_once_with(protocol, worker.workername)
        self.assertIsInstance(conn, msgpack.Connection)
コード例 #5
0
 def test_constructor(self):
     listener = msgpack.Listener(self.master)
     self.assertEqual(listener.master, self.master)
     self.assertEqual(listener._registrations, {})