コード例 #1
0
 def testClasses(self):
     bond = Bond()
     bond.name = u"ABB"
     bond.coupon = 1.5
     stock = Stock()
     stock.name = u"ABB"
     stock.paysDividend = True
     node1 = Node()
     self.assertEqual(yass.typeDesc(node1).id, 15)
     node1.id = 1.
     node2 = Node()
     node2.id = 2.
     node2.links = [node1, node2]
     try:
         uie = UnknownInstrumentsException()
         uie.instrumentIds = [Integer(333), Integer(444)]
         uie.onlyNeededForTests2 = b'abc'
         raise uie
     except UnknownInstrumentsException as e:
         pass
コード例 #2
0
ファイル: socket_client.py プロジェクト: dbrack/yass
def createObjects(withCycles=True) -> Any:
    stock = Stock()
    stock.id = Integer(123)
    stock.name = "YASS"
    stock.paysDividend = True

    unknownInstrumentsException = UnknownInstrumentsException()
    unknownInstrumentsException.instrumentIds = [Integer(1), Integer(2), Integer(3)]

    node1 = Node()
    node1.id = 1.0
    node2 = Node()
    node2.id = 2.0
    node2.links = []
    node1.links = [node1, node2]

    result = [
        None,
        False,
        True,
        Integer(123456),
        Integer(-987654),
        1.34545e98,
        "Hello",
        ">\u0001\u0012\u007F\u0080\u0234\u07FF\u0800\u4321\uFFFF<",
        bytes([0, 127, 256 - 1, 10, 256 - 45]),
        Expiration(2017, 11, 29),
        PriceKind.ASK,
        PriceKind.BID,
        stock,
        unknownInstrumentsException
    ]
    return cast(List[Node], result) + [node1] if withCycles else result
コード例 #3
0
ファイル: service_test.py プロジェクト: dbrack/yass
    def test(self):
        test = self

        class LocalClient(Client):
            def invoke(self, request):  # type: (Request) -> Reply
                ser = MessageSerializer(serializer)
                io = BytesIO()
                writer = createWriter(io)
                reader = createReader(io)

                def copy(input):  # type: (Any) -> Any
                    io.truncate(0)
                    io.seek(0)
                    ser.write(input, writer)
                    io.seek(0)
                    output = ser.read(reader)
                    test.assertEqual(io.read(1), b'')
                    return output

                return cast(Reply,
                            copy(server.invoke(cast(Request, copy(request)))))

        client = LocalClient()

        try:
            cast(Any, client.proxy(ACCEPTOR.echoService)).xxx()
            self.fail()
        except RuntimeError as e:
            self.assertEqual(str(e), "no method 'xxx' found for serviceId 2")

        echoService = client.proxy(ACCEPTOR.echoService)
        instrumentService = client.proxy(ACCEPTOR.instrumentService)
        self.assertEqual(echoService.echo(u"world"), u"world")
        try:
            echoService.echo(u"exception")
            self.fail()
        except SystemException as e:
            self.assertEqual(e.message, u"exception")
        instrumentService.showOneWay(True, Integer(2))
        self.assertEqual(instrumentService.getInstruments(), [])
コード例 #4
0
ファイル: socket_client.py プロジェクト: dbrack/yass
                s.close()

    return SocketClient()


def sslContext(trustStore: str, keyStore: str) -> SSLContext:
    sslContext = SSLContext(PROTOCOL_TLSv1_2)
    sslContext.verify_mode = CERT_REQUIRED
    storePath = "../../certificates/"
    sslContext.load_verify_locations(storePath + trustStore)
    sslContext.load_cert_chain(storePath + keyStore, password="******")
    sslContext.set_ciphers("AES128-SHA")
    return sslContext


if __name__ == "__main__":
    client = socketClient(defaultClientTransport(serializer), address, sslContext("Server.cert.pem", "Client.key.pem"))
    echoService = client.proxy(ACCEPTOR.echoService)
    instrumentService = client.proxy(ACCEPTOR.instrumentService, clientPrinter)
    print(echoService.echo("hello"))
    print(MyDumper(False).toString(echoService.echo(createObjects())))
    try:
        echoService.echo("exception")
    except SystemException as e:
        print(e.message)
    big = bytes(1_000_000)
    if len(echoService.echo(big)) != len(big):
        raise RuntimeError()
    instrumentService.showOneWay(True, Integer(123))
    print(instrumentService.getInstruments())
コード例 #5
0
ファイル: contract_test.py プロジェクト: dbrack/yass
 def testInteger(self):
     i = Integer(123)
     self.assertEqual(yass.typeDesc(i).id, 7)
     self.assertEqual(i.value, 123)
     self.assertEqual(str(i), '123')