Exemple #1
0
 def setUp(self):
     """
     Create a L{Store} with an L{AMPAvatar} installed on it.
     """
     self.store = Store()
     self.avatar = AMPAvatar(store=self.store)
     installOn(self.avatar, self.store)
     self.factory = StubBoxReceiverFactory(store=self.store,
                                           protocol=u"bar")
     self.store.powerUp(self.factory, IBoxReceiverFactory)
Exemple #2
0
class AMPAvatarTests(TestCase):
    """
    Tests for L{AMPAvatar} which provides an L{IBoxReceiver} implementation
    that supports routing messages to other L{IBoxReceiver} implementations.
    """
    def setUp(self):
        """
        Create a L{Store} with an L{AMPAvatar} installed on it.
        """
        self.store = Store()
        self.avatar = AMPAvatar(store=self.store)
        installOn(self.avatar, self.store)
        self.factory = StubBoxReceiverFactory(
            store=self.store, protocol=u"bar")
        self.store.powerUp(self.factory, IBoxReceiverFactory)


    def test_interface(self):
        """
        L{AMPAvatar} powers up the item on which it is installed for
        L{IBoxReceiver} and indirects that interface to the real router
        implementation of L{IBoxReceiver}.
        """
        router = IBoxReceiver(self.store)
        self.assertTrue(verifyObject(IBoxReceiver, router))
        self.assertNotIdentical(self.avatar, router)


    def test_connectorStarted(self):
        """
        L{AMPAvatar.indirect} returns a L{Router} with a started route
        connector as its default receiver.
        """
        receiver = SomeReceiver()
        self.avatar.__dict__['connectorFactory'] = lambda router: receiver
        router = self.avatar.indirect(IBoxReceiver)
        router.startReceivingBoxes(object())
        self.assertTrue(receiver.started)


    def test_reactor(self):
        """
        L{AMPAvatar.connectorFactory} returns a L{_RouteConnector} constructed
        using the global reactor.
        """
        connector = self.avatar.connectorFactory(object())
        self.assertIdentical(connector.reactor, reactor)
Exemple #3
0
class AMPAvatarTests(TestCase):
    """
    Tests for L{AMPAvatar} which provides an L{IBoxReceiver} implementation
    that supports routing messages to other L{IBoxReceiver} implementations.
    """
    def setUp(self):
        """
        Create a L{Store} with an L{AMPAvatar} installed on it.
        """
        self.store = Store()
        self.avatar = AMPAvatar(store=self.store)
        installOn(self.avatar, self.store)
        self.factory = StubBoxReceiverFactory(store=self.store,
                                              protocol=u"bar")
        self.store.powerUp(self.factory, IBoxReceiverFactory)

    def test_interface(self):
        """
        L{AMPAvatar} powers up the item on which it is installed for
        L{IBoxReceiver} and indirects that interface to the real router
        implementation of L{IBoxReceiver}.
        """
        router = IBoxReceiver(self.store)
        self.assertTrue(verifyObject(IBoxReceiver, router))
        self.assertNotIdentical(self.avatar, router)

    def test_connectorStarted(self):
        """
        L{AMPAvatar.indirect} returns a L{Router} with a started route
        connector as its default receiver.
        """
        receiver = SomeReceiver()
        self.avatar.__dict__['connectorFactory'] = lambda router: receiver
        router = self.avatar.indirect(IBoxReceiver)
        router.startReceivingBoxes(object())
        self.assertTrue(receiver.started)

    def test_reactor(self):
        """
        L{AMPAvatar.connectorFactory} returns a L{_RouteConnector} constructed
        using the global reactor.
        """
        connector = self.avatar.connectorFactory(object())
        self.assertIdentical(connector.reactor, reactor)
Exemple #4
0
 def setUp(self):
     """
     Create a L{Store} with an L{AMPAvatar} installed on it.
     """
     self.store = Store()
     self.avatar = AMPAvatar(store=self.store)
     installOn(self.avatar, self.store)
     self.factory = StubBoxReceiverFactory(
         store=self.store, protocol=u"bar")
     self.store.powerUp(self.factory, IBoxReceiverFactory)