Esempio n. 1
0
 def setUp(self):
     factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
     self.clock = task.Clock()
     factory.callLater = self.clock.callLater
     self.proto = factory.buildProtocol(('127.0.0.1', 0))
     self.proto.callLater = self.clock.callLater # Original in TimeoutMixin
     self.tr = proto_helpers.StringTransportWithDisconnection()
     self.proto.makeConnection(self.tr)
     self.tr.protocol = self.proto
Esempio n. 2
0
 def setUp(self):
     factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
     self.clock = task.Clock()
     factory.callLater = self.clock.callLater
     self.proto = factory.buildProtocol(('127.0.0.1', 0))
     self.proto.callLater = self.clock.callLater  # Original in TimeoutMixin
     self.tr = proto_helpers.StringTransportWithDisconnection()
     self.proto.makeConnection(self.tr)
     self.tr.protocol = self.proto
Esempio n. 3
0
class VOEventSubscriberFactoryTestCase(unittest.TestCase):
    def setUp(self):
        self.clock = task.Clock()
        self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
        self.factory.callLater = self.clock.callLater
        self.transport = proto_helpers.StringTransportWithDisconnection()
        self.proto = self.factory.buildProtocol(('127.0.0.1', 0))

    def tearDown(self):
        self.proto.connectionLost()

    def test_protocol(self):
        self.assertIsInstance(self.proto, VOEventSubscriber)

    def test_reconnect_delay(self):
        # Retries and delay are not reset immediately on connection, but
        # rather only after RESET_DELAY seconds have passed.
        self.factory.retries = VOEventSubscriberFactory.retries + 1
        self.factory.delay = VOEventSubscriberFactory.delay + 1
        self.proto.makeConnection(self.transport)
        self.assertNotEqual(self.factory.retries,
                            VOEventSubscriberFactory.retries)
        self.assertNotEqual(self.factory.delay, VOEventSubscriberFactory.delay)
        self.clock.advance(VOEventSubscriberFactory.RESET_DELAY)
        self.assertEqual(self.factory.retries,
                         VOEventSubscriberFactory.retries)
        self.assertEqual(self.factory.delay, VOEventSubscriberFactory.delay)
Esempio n. 4
0
def makeSubscriberService(endpoint, local_ivo, validators, handlers, filters):
    """Create a reconnecting VOEvent subscriber service.

    Parameters
    ----------
    endpoint : implements `twisted.internet.interfaces.IStreamClientEndpoint`
        The endpoint to which the service will connect.
    local_ivo : `str` or `None`
        IVOA identifier for the subscriber.
    validators : `list` of implementers of `~comet.icomet.IValidator`.
        Validators which will be applied to incoming events. Events which fail
        validation will be rejected.
    handlers : `list` of implementers of `~comet.icomet.IHandler`.
        Handlers to which events which pass validation will be passed.
    filters : `list` of `str`
        XPath filters. Will be passed to upstream as a request to filter the
        alerts being sent.

    Notes
    -----
    Upstream brokes may not provide support for XPath filtering; in this case,
    the filters suppplied will be ignored.

    Reconnection is handled according to the default policies of
    `twisted.application.internet.ClientService`.
    """
    factory = VOEventSubscriberFactory(local_ivo, validators,handlers, filters)
    service = ClientService(endpoint, factory)

    return service
Esempio n. 5
0
class VOEventSubscriberFactoryTestCase(unittest.TestCase):
    def setUp(self):
        self.clock = task.Clock()
        self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVORN)
        self.factory.callLater = self.clock.callLater
        self.transport = proto_helpers.StringTransportWithDisconnection()
        self.proto = self.factory.buildProtocol(('127.0.0.1', 0))

    def tearDown(self):
        self.proto.connectionLost()

    def test_protocol(self):
        self.assertIsInstance(self.proto, VOEventSubscriber)

    def test_reconnect_delay(self):
        # Retries and delay are not reset immediately on connection, but
        # rather only after RESET_DELAY seconds have passed.
        self.factory.retries = VOEventSubscriberFactory.retries + 1
        self.factory.delay = VOEventSubscriberFactory.delay + 1
        self.proto.makeConnection(self.transport)
        self.assertNotEqual(self.factory.retries, VOEventSubscriberFactory.retries)
        self.assertNotEqual(self.factory.delay, VOEventSubscriberFactory.delay)
        self.clock.advance(VOEventSubscriberFactory.RESET_DELAY)
        self.assertEqual(self.factory.retries, VOEventSubscriberFactory.retries)
        self.assertEqual(self.factory.delay, VOEventSubscriberFactory.delay)
Esempio n. 6
0
class VOEventSubscriberFactoryTestCase(unittest.TestCase):
    def setUp(self):
        self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
        self.transport = proto_helpers.StringTransportWithDisconnection()
        self.proto = self.factory.buildProtocol(('127.0.0.1', 0))

    def tearDown(self):
        self.proto.connectionLost()

    def test_protocol(self):
        self.assertIsInstance(self.proto, VOEventSubscriber)
class VOEventSubscriberFactoryTestCase(unittest.TestCase):
    def setUp(self):
        self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
        self.transport = proto_helpers.StringTransportWithDisconnection()
        self.proto = self.factory.buildProtocol(('127.0.0.1', 0))

    def tearDown(self):
        self.proto.connectionLost()

    def test_protocol(self):
        self.assertIsInstance(self.proto, VOEventSubscriber)
Esempio n. 8
0
 def setUp(self):
     factory = VOEventSubscriberFactory(self.IVOID)
     factory.callLater = task.Clock().callLater
     self.proto = factory.buildProtocol(('127.0.0.1', 0))
     self.tr = proto_helpers.StringTransport()
     self.proto.makeConnection(self.tr)
Esempio n. 9
0
 def setUp(self):
     self.clock = task.Clock()
     self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
     self.factory.callLater = self.clock.callLater
     self.transport = proto_helpers.StringTransportWithDisconnection()
     self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
Esempio n. 10
0
 def setUp(self):
     factory = VOEventSubscriberFactory(self.IVOID)
     factory.callLater = task.Clock().callLater
     self.proto = factory.buildProtocol(('127.0.0.1', 0))
     self.tr = proto_helpers.StringTransport()
     self.proto.makeConnection(self.tr)
Esempio n. 11
0
 def setUp(self):
     self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVOID)
     self.transport = proto_helpers.StringTransportWithDisconnection()
     self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
Esempio n. 12
0
 def setUp(self):
     self.clock = task.Clock()
     self.factory = VOEventSubscriberFactory(DUMMY_EVENT_IVORN)
     self.factory.callLater = self.clock.callLater
     self.transport = proto_helpers.StringTransportWithDisconnection()
     self.proto = self.factory.buildProtocol(('127.0.0.1', 0))