示例#1
0
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
示例#2
0
 def testInstance(self):
     self.assertTrue(isinstance(False, bool))
     self.assertTrue(isinstance(True, bool))
     self.assertTrue(isinstance(
         False, int))  # note: therefore int test must be after bool test
     self.assertTrue(isinstance(
         True, int))  # note: therefore int test must be after bool test
     self.assertTrue(isinstance(0, int))
     self.assertTrue(isinstance(1, int))
     self.assertFalse(isinstance(1., int))
     self.assertFalse(isinstance(1, float))
     self.assertTrue(isinstance(1., float))
     self.assertTrue(isinstance(123.456e77, float))
     self.assertTrue(isinstance('', str))
     self.assertTrue(isinstance('a', str))
     self.assertTrue(isinstance('aaa', str))
     self.assertTrue(isinstance(u'aaa', unicode))
     self.assertFalse(isinstance('aaa', unicode))
     self.assertFalse(isinstance(u'aaa', str))
     self.assertTrue(isinstance(b'abc', str))
     self.assertTrue(isinstance(b'abc', bytes))
     self.assertTrue(isinstance('abc', bytes))
     self.assertTrue(isinstance([], list))
     self.assertTrue(isinstance([True, 1], list))
     self.assertFalse(hasattr(1, yass.TYPE_DESC))
     self.assertTrue(hasattr(PriceKind.ASK, yass.TYPE_DESC))
     self.assertTrue(hasattr(Node(), yass.TYPE_DESC))
示例#3
0
 def testClasses(self):
     bond = Bond()
     bond.name = "ABB"
     bond.coupon = 1.5
     stock = Stock()
     stock.name = "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
示例#4
0
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
示例#5
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