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)
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)
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)
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"])
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)
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)
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)
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()))
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
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
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)
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)
def setUp(self): self.message = broker_test_message(DUMMY_SERVICE_IVOID.decode())
def setUp(self): self.config = Options() self.cmd_line = ["--local-ivo", DUMMY_SERVICE_IVOID.decode()]
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()]
def test_valid_ivoid(self): self.config.parseOptions(self.cmd_line) self.assertEqual(self.config['local-ivo'], DUMMY_SERVICE_IVOID.decode())
def setUp(self): self.message = VOEventMessage.broker_test(DUMMY_SERVICE_IVOID.decode())