コード例 #1
0
 def setUp(self, test_interval=BCAST_TEST_INTERVAL):
     self.factory = VOEventBroadcasterFactory(DUMMY_SERVICE_IVOID.decode(),
                                              test_interval)
     self.factory.alive_loop.clock = task.Clock()
     self.factory.test_loop.clock = task.Clock()
     self.factory.broadcasters.append(DummyBroadcaster())
     self.connector = reactor.listenTCP(0, self.factory)
コード例 #2
0
 def test_receive_iamalive(self):
     self.proto.stringReceived(DUMMY_IAMALIVE)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("iamalive", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
コード例 #3
0
 def test_receive_authenticate(self):
     self.proto.stringReceived(DUMMY_AUTHENTICATE)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("authenticate", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
コード例 #4
0
 def test_receive_authenticate(self):
     self.proto.stringReceived(DUMMY_AUTHENTICATE)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("authenticate", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
コード例 #5
0
ファイル: test_broker.py プロジェクト: jdswinbank/Comet
    def test_local_ivoid(self):
        # The local IVOID should be set correctly.
        self.config.parseOptions(self.cmd_line)
        self.assertEqual(self.config['local_ivo'], DUMMY_SERVICE_IVOID.decode())

        # And a bad one rejected.
        self._check_bad_parse(["--local-ivo", "bad_ivo"])
コード例 #6
0
 def test_receive_iamalive(self):
     self.proto.stringReceived(DUMMY_IAMALIVE)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("iamalive", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
コード例 #7
0
 def test_sendIAmAlive(self):
     self.tr.clear()
     init_alive_count = self.proto.alive_count
     self.factory.alive_loop.clock.advance(self.factory.IAMALIVE_INTERVAL)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("iamalive", received_element.attrib['role'])
     self.assertEqual(DUMMY_SERVICE_IVOID.decode(), received_element.find('Origin').text)
     self.assertEqual(self.proto.alive_count - init_alive_count, 1)
コード例 #8
0
 def setUp(self, test_interval=BCAST_TEST_INTERVAL):
     self.factory = VOEventBroadcasterFactory(
         DUMMY_SERVICE_IVOID.decode(), test_interval
     )
     self.factory.alive_loop.clock = task.Clock()
     self.factory.test_loop.clock = task.Clock()
     self.factory.broadcasters.append(DummyBroadcaster())
     self.connector = reactor.listenTCP(0, self.factory)
コード例 #9
0
ファイル: test_broker.py プロジェクト: andrewzwaniga/Comet
    def test_local_ivoid(self):
        # The local IVOID should be set correctly.
        self.config.parseOptions(self.cmd_line)
        self.assertEqual(self.config['local_ivo'],
                         DUMMY_SERVICE_IVOID.decode())

        # And a bad one rejected.
        self._check_bad_parse(["--local-ivo", "bad_ivo"])
コード例 #10
0
 def test_receive_valid_voevent(self):
     self.proto.stringReceived(DUMMY_VOEVENT)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("ack", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
     self.assertEqual(DUMMY_EVENT_IVOID.decode(),
                      received_element.find('Origin').text)
コード例 #11
0
 def test_receive_valid_voevent(self):
     self.proto.stringReceived(DUMMY_VOEVENT)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("ack", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
     self.assertEqual(DUMMY_EVENT_IVOID.decode(),
                      received_element.find('Origin').text)
コード例 #12
0
 def test_sendIAmAlive(self):
     self.tr.clear()
     init_alive_count = self.proto.alive_count
     self.factory.alive_loop.clock.advance(self.factory.IAMALIVE_INTERVAL)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("iamalive", received_element.attrib['role'])
     self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                      received_element.find('Origin').text)
     self.assertEqual(self.proto.alive_count - init_alive_count, 1)
コード例 #13
0
ファイル: test_voevent.py プロジェクト: andrewzwaniga/Comet
 def test_valid(self):
     schema = etree.XMLSchema(
         etree.parse(
             os.path.join(comet.__path__[0], "schema/VOEvent-v2.0.xsd")
         )
     )
     self.assertTrue(schema.validate(self.message.element))
     self.assertEqual(self.message.role, "test")
     self.assertTrue(self.message.ivoid.startswith(DUMMY_SERVICE_IVOID.decode()))
コード例 #14
0
 def setUp(self):
     self.factory = VOEventBroadcasterFactory(DUMMY_SERVICE_IVOID.decode(),
                                              BCAST_TEST_INTERVAL)
     self.factory.alive_loop.clock = task.Clock()
     self.factory.test_loop.clock = task.Clock()
     self.connector = reactor.listenTCP(0, self.factory)
     self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
     self.tr = proto_helpers.StringTransportWithDisconnection()
     self.proto.makeConnection(self.tr)
     self.tr.protocol = self.proto
コード例 #15
0
 def setUp(self):
     self.factory = VOEventBroadcasterFactory(
         DUMMY_SERVICE_IVOID.decode(), BCAST_TEST_INTERVAL
     )
     self.factory.alive_loop.clock = task.Clock()
     self.factory.test_loop.clock = task.Clock()
     self.connector = reactor.listenTCP(0, self.factory)
     self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
     self.tr = proto_helpers.StringTransportWithDisconnection()
     self.proto.makeConnection(self.tr)
     self.tr.protocol = self.proto
コード例 #16
0
 def test_receive_invalid_voevent(self):
     # This should not be accepted, but *should not* generate a NAK.
     def invalid(event): raise Exception("Failed")
     self.proto.factory.validators.append(invalid)
     self.proto.stringReceived(DUMMY_VOEVENT)
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("ack", received_element.attrib['role'])
     if self.IVOID:
         self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                          received_element.find('Response').text)
     self.assertEqual(DUMMY_EVENT_IVOID.decode(),
                      received_element.find('Origin').text)
コード例 #17
0
    def test_receive_invalid_voevent(self):
        # This should not be accepted, but *should not* generate a NAK.
        def invalid(event):
            raise Exception("Failed")

        self.proto.factory.validators.append(invalid)
        self.proto.stringReceived(DUMMY_VOEVENT)
        received_element = etree.fromstring(self.tr.value()[4:])
        self.assertEqual("ack", received_element.attrib['role'])
        if self.IVOID:
            self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                             received_element.find('Response').text)
        self.assertEqual(DUMMY_EVENT_IVOID.decode(),
                         received_element.find('Origin').text)
コード例 #18
0
 def test_sent_authenticate(self):
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("authenticate", received_element.attrib['role'])
     self.assertEqual(DUMMY_SERVICE_IVOID.decode(), received_element.find('Origin').text)
コード例 #19
0
 def setUp(self):
     self.message = broker_test_message(DUMMY_SERVICE_IVOID.decode())
コード例 #20
0
 def test_sent_authenticate(self):
     received_element = etree.fromstring(self.tr.value()[4:])
     self.assertEqual("authenticate", received_element.attrib['role'])
     self.assertEqual(DUMMY_SERVICE_IVOID.decode(),
                      received_element.find('Origin').text)
コード例 #21
0
ファイル: test_broker.py プロジェクト: andrewzwaniga/Comet
 def setUp(self):
     self.config = Options()
     self.cmd_line = ["--local-ivo", DUMMY_SERVICE_IVOID.decode()]
コード例 #22
0
 def setUp(self):
     self.config = Options()
     # Note that parsing from the command line always results in a str,
     # regardless of whether we're running Python 2.
     self.cmd_line = ["--local-ivo", DUMMY_SERVICE_IVOID.decode()]
コード例 #23
0
 def test_valid_ivoid(self):
     self.config.parseOptions(self.cmd_line)
     self.assertEqual(self.config['local-ivo'], DUMMY_SERVICE_IVOID.decode())
コード例 #24
0
ファイル: test_voevent.py プロジェクト: andrewzwaniga/Comet
 def setUp(self):
     self.message = VOEventMessage.broker_test(DUMMY_SERVICE_IVOID.decode())
コード例 #25
0
ファイル: test_broker.py プロジェクト: jdswinbank/Comet
 def setUp(self):
     self.config = Options()
     self.cmd_line = ["--local-ivo", DUMMY_SERVICE_IVOID.decode()]