コード例 #1
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     stmttrn = Aggregate.from_etree(bk_stmt.StmttrnTestCase.etree)
     self.assertEqual(instance.trntype, stmttrn.trntype)
     self.assertEqual(instance.dtposted, stmttrn.dtposted)
     self.assertEqual(instance.trnamt, stmttrn.trnamt)
     self.assertEqual(instance.fitid, stmttrn.fitid)
     self.assertEqual(instance.memo, stmttrn.memo)
コード例 #2
0
ファイル: test_models_base.py プロジェクト: csingley/ofxtools
    def testFromEtreeWrongOrder(self):
        root = ET.Element("TESTLIST")
        agg = ET.SubElement(root, "TESTAGGREGATE2")
        ET.SubElement(agg, "METADATA").text = "dumbo"
        ET.SubElement(root, "METADATA").text = "foo"

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #3
0
    def testMultipleCcacctinfo(cls):
        root = Element("ACCTINFO")
        ccacctinfo = bk_stmt.CcacctinfoTestCase.etree
        root.append(ccacctinfo)
        root.append(ccacctinfo)

        with cls.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #4
0
    def testMultipleInvacctinfo(cls):
        root = Element("ACCTINFO")
        invacctinfo = invest.InvacctinfoTestCase.etree
        root.append(invacctinfo)
        root.append(invacctinfo)

        with cls.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #5
0
    def testListItems(self):
        # PROFMSGSRSV1 may only contain PROFTRNRS
        listitems = PROFMSGSRSV1.listitems
        self.assertEqual(len(listitems), 1)
        root = self.etree
        root.append(profile.ProftrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #6
0
    def testListItems(self):
        # EMAILMSGSRSV1 may contain ["MAILTRNRS", "GETMIMETRNRS", "MAILSYNCRS"]
        listitems = EMAILMSGSRSV1.listitems
        self.assertEqual(len(listitems), 3)
        root = self.etree
        root.append(email.MailtrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #7
0
    def testListItems(cls):
        # INVPOSLIST may only contain
        # ['POSDEBT', 'POSMF', 'POSOPT', 'POSOTHER', 'POSSTOCK', ]
        listitems = INVPOSLIST.listitems
        cls.assertEqual(len(listitems), 5)
        root = cls.etree
        root.append(bk_stmt.StmttrnTestCase.etree)

        with cls.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #8
0
    def testListItems(self):
        # SECLISTMSGSRSV1 may only contain SECLISTTRNRS, SECLIST

        listitems = SECLISTMSGSRSV1.listitems
        self.assertEqual(len(listitems), 2)
        root = self.etree
        root.append(securities.SeclisttrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #9
0
    def testListItems(self):
        # INVSTMTMSGSRSV1 may only contain
        # ["INVSTMTTRNRS", "INVMAILTRNRS", "INVMAILSYNCRS"]
        listitems = INVSTMTMSGSRSV1.listitems
        self.assertEqual(len(listitems), 3)
        root = self.etree
        root.append(invest.InvstmttrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #10
0
    def testListItems(self):
        # SIGNUPMSGSRSV1 may contain
        # ["ENROLLTRNRS", "ACCTINFOTRNRS", "ACCTTRNRS", "CHGUSERINFOTRNRS"]
        listitems = SIGNUPMSGSRSV1.listitems
        self.assertEqual(len(listitems), 4)
        root = self.etree
        root.append(signup.EnrolltrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #11
0
    def testListItems(self):
        # INTERXFERMSGSRSV1 may contain
        # ["INTERTRNRS", "RECINTERTRNRS", "INTERSYNCRS", "RECINTERSYNCRS"]
        listitems = INTERXFERMSGSRSV1.listitems
        self.assertEqual(len(listitems), 4)
        root = self.etree
        root.append(interxfer.IntertrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #12
0
    def testListItems(self):
        # WIRERXFERMSGSRSV1 may contain
        # ["WIRETRNRS", "WIRESYNCRS"]
        listitems = WIREXFERMSGSRSV1.listitems
        self.assertEqual(len(listitems), 2)
        root = self.etree
        root.append(wire.WiretrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #13
0
ファイル: test_models_base.py プロジェクト: csingley/ofxtools
    def testFromEtreeMissingRequired(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "REQ00").text = "Y"
        ET.SubElement(root, "REQ11").text = "N"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #14
0
ファイル: base.py プロジェクト: csingley/ofxtools
 def testOptional(self):
     if self.optionalElements:
         for tag in self.optionalElements:
             etree = deepcopy(self.etree)
             child = etree.find(tag)
             try:
                 etree.remove(child)
             except TypeError:
                 msg = "Can't find {} (from optionalElements) under {}"
                 raise ValueError(msg.format(tag, etree.tag))
             Aggregate.from_etree(etree)
コード例 #15
0
    def testListItems(self):
        # INVOOLIST may only contain
        # ['OOBUYDEBT', 'OOBUYMF', 'OOBUYOPT', 'OOBUYOTHER',
        # 'OOBUYSTOCK', 'OOSELLDEBT', 'OOSELLMF', 'OOSELLOPT',
        # 'OOSELLOTHER', 'OOSELLSTOCK', 'SWITCHMF', ]
        listitems = INVOOLIST.listitems
        self.assertEqual(len(listitems), 11)
        root = self.etree
        root.append(bk_stmt.StmttrnTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #16
0
ファイル: base.py プロジェクト: csingley/ofxtools
 def testRequired(self):
     if self.requiredElements:
         for tag in self.requiredElements:
             etree = deepcopy(self.etree)
             child = etree.find(tag)
             try:
                 etree.remove(child)
             except TypeError:
                 msg = "Can't find {} (from requiredElements) under {}"
                 raise ValueError(msg.format(tag, etree.tag))
             with self.assertRaises(ValueError):
                 Aggregate.from_etree(etree)
コード例 #17
0
    def testListItems(self):
        # BANKMSGSRSV! may contain
        # ["STMTTRNRS", "STMTENDRS", "STPCHKTRNRS", "INTRATRNRS",
        # "RECINTRATRNRS", "BANKMAILTRNRS", "STPCHKSYNCRS", "INTRASYNCRS",
        # "RECINTRASYNCRS", "BANKMAILSYNCRS"]
        listitems = BANKMSGSRSV1.listitems
        self.assertEqual(len(listitems), 10)
        root = self.etree
        root.append(bk_stmt.StmttrnrqTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #18
0
    def testListItems(self):
        # MSGSETLIST may only contain
        # ["SIGNONMSGSET", "SIGNUPMSGSET", "PROFMSGSET", "BANKMSGSET",
        # "CREDITCARDMSGSET", "INTERXFERMSGSET", "WIREXFERMSGSET",
        # "EMAILMSGSET", "INVSTMTMSGSET", "SECLISTMSGSET", "BILLPAYMSGSET",
        # "PRESDIRMSGSET", "PRESDLVMSGSET", "TAX1099MSGSET"]
        listitems = MSGSETLIST.listitems
        #  cls.assertEqual(len(listitems), 13)
        self.assertEqual(len(listitems), 12)
        root = self.etree
        root.append(bk_stmt.StmttrnrsTestCase.etree)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #19
0
ファイル: test_models_base.py プロジェクト: csingley/ofxtools
    def testFromEtreeWrongOrder(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "DONTUSE").text = "dontuse"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"
        ET.SubElement(root, "METADATA").text = "metadata"

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "DONTUSE").text = "dontuse"
        ET.SubElement(root, "METADATA").text = "metadata"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "DONTUSE").text = "dontuse"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "METADATA").text = "metadata"

        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #20
0
ファイル: base.py プロジェクト: csingley/ofxtools
    def oneOfTest(self, tag, texts):
        # Make sure OneOf validator allows all legal values and disallows
        # illegal values
        for text in texts:
            etree = deepcopy(self.etree)
            target = etree.find(".//%s" % tag)
            target.text = text
            Aggregate.from_etree(etree)

        etree = deepcopy(self.etree)
        target = etree.find(".//%s" % tag)
        target.text = "garbage"
        with self.assertRaises(ValueError):
            Aggregate.from_etree(etree)
コード例 #21
0
ファイル: test_models_ofx.py プロジェクト: csingley/ofxtools
 def testUnsupported(self):
     instance = Aggregate.from_etree(self.root)
     unsupported = list(instance.unsupported)
     self.assertEqual(unsupported, self.unsupported)
     for unsupp in unsupported:
         setattr(instance, unsupp, "FOOBAR")
         self.assertIsNone(getattr(instance, unsupp))
コード例 #22
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     self.assertEqual(instance.fitid, instance.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invtran.memo)
     self.assertEqual(instance.uniqueid, instance.secid.uniqueid)
     self.assertEqual(instance.uniqueidtype, instance.secid.uniqueidtype)
コード例 #23
0
 def testConvertSecnameTooLong(self):
     """ Don't enforce length restriction on SECNAME; raise Warning """
     # Issue #12
     root = self.etree
     root[1].text = """
     There is a theory going around that the U.S.A. was and still is a
     gigantic Masonic plot under the ultimate control of the group known as
     the Illuminati. It is difficult to look for long at the strange single
     eye crowning the pyramid which is found on every dollar bill and not
     begin to believe the story, a little. Too many anarchists in
     19th-century Europe — Bakunin, Proudhon, Salverio Friscia — were Masons
     for it to be pure chance. Lovers of global conspiracy, not all of them
     Catholic, can count on the Masons for a few good shivers and voids when
     all else fails.
     """
     with self.assertWarns(Warning):
         instance = Aggregate.from_etree(root)
     self.assertEqual(
         instance.secname,
         """
     There is a theory going around that the U.S.A. was and still is a
     gigantic Masonic plot under the ultimate control of the group known as
     the Illuminati. It is difficult to look for long at the strange single
     eye crowning the pyramid which is found on every dollar bill and not
     begin to believe the story, a little. Too many anarchists in
     19th-century Europe — Bakunin, Proudhon, Salverio Friscia — were Masons
     for it to be pure chance. Lovers of global conspiracy, not all of them
     Catholic, can count on the Masons for a few good shivers and voids when
     all else fails.
     """)
コード例 #24
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     self.assertEqual(instance.fitid, instance.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invtran.memo)
     self.assertEqual(instance.curtype, "CURRENCY")
     self.assertEqual(instance.cursym, instance.currency.cursym)
     self.assertEqual(instance.currate, instance.currency.currate)
コード例 #25
0
ファイル: Parser.py プロジェクト: csingley/ofxtools
 def convert(self) -> Aggregate:
     """
     Transform tree of `ElementTree.Element` instances into hierarchy of
     `ofxtools.models.base.Aggregate` & `ofxtools.Types.Element` instances.
     """
     if not isinstance(self._root, ET.Element):
         raise ValueError("Must first call parse() to have data to convert")
     instance = Aggregate.from_etree(self._root)
     return instance
コード例 #26
0
ファイル: test_models_base.py プロジェクト: csingley/ofxtools
    def testFromEtree(self):
        instance = Aggregate.from_etree(self.root)
        self.assertIsInstance(instance, TESTLIST)
        self.assertEqual(instance.metadata, "foo")
        self.assertEqual(len(instance), 3)
        agg0, agg1, agg2 = instance[:]

        self.assertIsInstance(agg0, TESTAGGREGATE)
        self.assertIsInstance(agg1, TESTAGGREGATE)
        self.assertIsInstance(agg2, TESTAGGREGATE2)
コード例 #27
0
 def testPropertyAliases(cls):
     instance = Aggregate.from_etree(cls.etree)
     cls.assertEqual(instance.uniqueid, instance.secid.uniqueid)
     cls.assertEqual(instance.uniqueidtype, instance.secid.uniqueidtype)
     #  cls.assertEqual(instance.heldinacct, instance.invpos.heldinacct)
     #  cls.assertEqual(instance.postype, instance.invpos.postype)
     #  cls.assertEqual(instance.units, instance.invpos.units)
     #  cls.assertEqual(instance.unitprice, instance.invpos.unitprice)
     #  cls.assertEqual(instance.mktval, instance.invpos.mktval)
     #  cls.assertEqual(instance.dtpriceasof, instance.invpos.dtpriceasof)
     cls.assertEqual(instance.cursym, instance.currency.cursym)
     cls.assertEqual(instance.currate, instance.currency.currate)
コード例 #28
0
    def testMixedXxxacctto(self):
        bankacctfrom = BankacctfromTestCase().root
        bankacctto = BankaccttoTestCase().root
        ccacctto = CcaccttoTestCase().root
        invacctto = InvaccttoTestCase().root

        root = Element("SVCADD")
        root.append(bankacctfrom)
        root.append(bankacctto)
        root.append(ccacctto)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("SVCADD")
        root.append(bankacctfrom)
        root.append(bankacctto)
        root.append(invacctto)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("SVCADD")
        root.append(bankacctfrom)
        root.append(bankacctto)
        root.append(invacctto)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
コード例 #29
0
    def testFromEtreeDuplicates(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "METADATA").text = "metadata"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        with self.assertRaises(OFXSpecError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        with self.assertRaises(OFXSpecError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        with self.assertRaises(OFXSpecError):
            Aggregate.from_etree(root)
コード例 #30
0
ファイル: test_models_base.py プロジェクト: csingley/ofxtools
    def testFromEtreeMissingUnrequired(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "REQ00").text = "Y"
        ET.SubElement(root, "REQ11").text = "N"
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        instance = Aggregate.from_etree(root)
        self.assertIsInstance(instance, TESTAGGREGATE)
        self.assertEqual(instance.metadata, "metadata")
        self.assertEqual(instance.req00, True)
        self.assertEqual(instance.req11, False)
        self.assertIsNone(instance.dontuse)
コード例 #31
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     self.assertEqual(instance.fitid, instance.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invtran.memo)
     self.assertEqual(instance.uniqueid, instance.secid.uniqueid)
     self.assertEqual(instance.uniqueidtype, instance.secid.uniqueidtype)
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertIsNone(instance.origcurrency)
     self.assertEqual(instance.currency.__class__.__name__, "CURRENCY")
     self.assertEqual(instance.curtype, "CURRENCY")
     self.assertEqual(instance.cursym, instance.currency.cursym)
     self.assertEqual(instance.currate, instance.currency.currate)
コード例 #32
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     self.assertEqual(instance.fitid, instance.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invtran.memo)
     self.assertEqual(instance.uniqueid, instance.secid.uniqueid)
     self.assertEqual(instance.uniqueidtype, instance.secid.uniqueidtype)
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertIsNone(instance.origcurrency)
     self.assertEqual(instance.currency.__class__.__name__, "CURRENCY")
     self.assertEqual(instance.curtype, "CURRENCY")
     self.assertEqual(instance.cursym, instance.currency.cursym)
     self.assertEqual(instance.currate, instance.currency.currate)
コード例 #33
0
 def testConvert(self):
     # Test *TRNRQ Aggregate and direct child Elements.
     # Everything below that is tested elsewhere.
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INVSTMTRQ)
     self.assertIsInstance(instance.invacctfrom, INVACCTFROM)
     self.assertIsInstance(instance.inctran, INCTRAN)
     self.assertEqual(instance.incoo, False)
     self.assertIsInstance(instance.incpos, INCPOS)
     self.assertEqual(instance.incbal, False)
     self.assertEqual(instance.inc401k, True)
     self.assertEqual(instance.inc401kbal, False)
     self.assertEqual(instance.inctranimg, True)
コード例 #34
0
 def testConvert(self):
     # Test **RS Aggregate and direct child Elements.
     # Everything below that is tested elsewhere.
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INVSTMTRS)
     self.assertEqual(instance.dtasof, datetime(2001, 5, 30, tzinfo=UTC))
     self.assertEqual(instance.curdef, "USD")
     self.assertIsInstance(instance.invacctfrom, INVACCTFROM)
     self.assertIsInstance(instance.invtranlist, INVTRANLIST)
     self.assertIsInstance(instance.invposlist, INVPOSLIST)
     self.assertIsInstance(instance.invbal, INVBAL)
     #  self.assertIsInstance(instance.invoolist, INVOOLIST)
     self.assertEqual(instance.mktginfo, "Get Free Stuff NOW!!")
コード例 #35
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, INVOICE)
     self.assertEqual(root.invno, "103")
     self.assertEqual(root.invtotalamt, Decimal("25"))
     self.assertEqual(root.invpaidamt, Decimal("25"))
     self.assertEqual(root.invdate, datetime(2015, 9, 6, tzinfo=UTC))
     self.assertEqual(root.invdesc, "Purchase invoice")
     self.assertIsInstance(root.discount, DISCOUNT)
     self.assertIsInstance(root.adjustment, ADJUSTMENT)
     self.assertEqual(len(root), 2)
     for item in root:
         self.assertIsInstance(item, LINEITEM)
コード例 #36
0
    def testFromEtreeMissingUnrequired(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "REQ00").text = "Y"
        ET.SubElement(root, "REQ11").text = "N"
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        instance = Aggregate.from_etree(root)
        self.assertIsInstance(instance, TESTAGGREGATE)
        self.assertEqual(instance.metadata, "metadata")
        self.assertEqual(instance.req00, True)
        self.assertEqual(instance.req11, False)
        self.assertIsNone(instance.dontuse)
コード例 #37
0
 def testPropertyAliases(cls):
     instance = Aggregate.from_etree(cls.etree)
     cls.assertEqual(instance.uniqueid, instance.invpos.secid.uniqueid)
     cls.assertEqual(instance.uniqueidtype,
                     instance.invpos.secid.uniqueidtype)
     cls.assertEqual(instance.heldinacct, instance.invpos.heldinacct)
     cls.assertEqual(instance.postype, instance.invpos.postype)
     cls.assertEqual(instance.units, instance.invpos.units)
     cls.assertEqual(instance.unitprice, instance.invpos.unitprice)
     cls.assertEqual(instance.mktval, instance.invpos.mktval)
     cls.assertEqual(instance.dtpriceasof, instance.invpos.dtpriceasof)
     cls.assertEqual(instance.cursym, instance.invpos.currency.cursym)
     cls.assertEqual(instance.currate, instance.invpos.currency.currate)
コード例 #38
0
ファイル: test_models_email.py プロジェクト: yetaai/ofxtools
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, MAIL)
     self.assertEqual(instance.userid, "somebody")
     self.assertEqual(instance.dtcreated,
                      datetime(1999, 9, 9, 11, tzinfo=UTC))
     # FROM (reserved Python keyword) renamed to "frm"
     self.assertEqual(instance.frm, "*****@*****.**")
     self.assertEqual(instance.to, "*****@*****.**")
     self.assertEqual(instance.subject, "I've got a problem")
     self.assertEqual(instance.msgbody, "All my money is gone")
     self.assertEqual(instance.incimages, False)
     self.assertEqual(instance.usehtml, False)
コード例 #39
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.etree)
     self.assertEqual(instance.uniqueid, instance.invsell.secid.uniqueid)
     self.assertEqual(instance.uniqueidtype, instance.invsell.secid.uniqueidtype)
     self.assertEqual(instance.units, instance.invsell.units)
     self.assertEqual(instance.unitprice, instance.invsell.unitprice)
     self.assertEqual(instance.total, instance.invsell.total)
     self.assertEqual(instance.curtype, instance.invsell.curtype)
     self.assertEqual(instance.cursym, instance.invsell.cursym)
     self.assertEqual(instance.currate, instance.invsell.currate)
     self.assertEqual(instance.subacctsec, instance.invsell.subacctsec)
     self.assertEqual(instance.fitid, instance.invsell.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invsell.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invsell.invtran.memo)
コード例 #40
0
ファイル: test_bank.py プロジェクト: fergbrain/ofxtools
 def testConvert(self):
     # Test *TRNRS wrapper and **RS Aggregate.
     # Everything below that is tested elsewhere.
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, STMTRS)
     self.assertIn(root.curdef, CURRENCY_CODES)
     self.assertIsInstance(root.bankacctfrom, BANKACCTFROM)
     self.assertIsInstance(root.banktranlist, BANKTRANLIST)
     self.assertIsInstance(root.ledgerbal, LEDGERBAL)
     self.assertIsInstance(root.availbal, AVAILBAL)
     self.assertEqual(root.cashadvbalamt, Decimal('10000'))
     self.assertEqual(root.intrate, Decimal('20.99'))
     self.assertIsInstance(root.ballist, BALLIST)
     self.assertEqual(root.mktginfo, 'Get Free Stuff NOW!!')
コード例 #41
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, MSGSETCORE)
     self.assertEqual(root.ver, 1)
     self.assertEqual(root.url, 'https://ofxs.ameritrade.com/cgi-bin/apps/OFX')
     self.assertEqual(root.ofxsec, 'NONE')
     self.assertEqual(root.transpsec, True)
     self.assertEqual(root.signonrealm, 'AMERITRADE')
     self.assertEqual(root.language, 'ENG')
     self.assertEqual(root.syncmode, 'FULL')
     self.assertEqual(root.refreshsupt, False)
     self.assertEqual(root.respfileer, False)
     self.assertEqual(root.spname, 'Dewey Cheatham & Howe')
     self.assertIsInstance(root.ofxextension, OFXEXTENSION)
コード例 #42
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INCOME)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.incometype, "CGLONG")
     self.assertEqual(instance.total, Decimal("1500"))
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.subacctfund, "CASH")
     self.assertEqual(instance.taxexempt, True)
     self.assertEqual(instance.withholding, Decimal("123.45"))
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #43
0
ファイル: test_models_ofx.py プロジェクト: fergbrain/ofxtools
 def testPropertyAliases(self):
     # Make sure class property aliases have been defined correctly
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root.sonrs, SONRS)
     self.assertIsInstance(root.securities, SECLIST)
     self.assertIsInstance(root.statements, list)
     # *MSGSRSV1 test cases include 2 of each *STMTRS
     self.assertEqual(len(root.statements), 6)
     self.assertIsInstance(root.statements[0], STMTRS)
     self.assertIsInstance(root.statements[1], STMTRS)
     self.assertIsInstance(root.statements[2], CCSTMTRS)
     self.assertIsInstance(root.statements[3], CCSTMTRS)
     self.assertIsInstance(root.statements[4], INVSTMTRS)
     self.assertIsInstance(root.statements[5], INVSTMTRS)
コード例 #44
0
    def testFromEtree(self):
        instance = Aggregate.from_etree(self.root)
        self.assertIsInstance(instance, TESTELEMENTLIST)
        self.assertEqual(instance.metadata, "something")
        self.assertEqual(len(instance), 2)
        self.assertEqual(instance[0], False)
        self.assertEqual(instance[1], True)

        # Out of order - invalid
        root = ET.Element("TESTELEMENTLIST")
        ET.SubElement(root, "TAG").text = "N"
        ET.SubElement(root, "TAG").text = "Y"
        ET.SubElement(root, "METADATA").text = "something"

        with self.assertRaises(OFXSpecError):
            Aggregate.from_etree(root)

        root = ET.Element("TESTELEMENTLIST")
        ET.SubElement(root, "TAG").text = "N"
        ET.SubElement(root, "METADATA").text = "something"
        ET.SubElement(root, "TAG").text = "Y"

        with self.assertRaises(OFXSpecError):
            Aggregate.from_etree(root)
コード例 #45
0
 def testConvert(self):
     # Make sure Aggregate.from_etree() calls Element.convert() and sets
     # Aggregate instance attributes with the result
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, SONRS)
     self.assertIsInstance(root.status, STATUS)
     self.assertEqual(root.dtserver, datetime(2005, 10, 29, 10, 10, 3))
     self.assertEqual(root.userkey, 'DEADBEEF')
     self.assertEqual(root.tskeyexpire, datetime(2005, 12, 31))
     self.assertEqual(root.language, 'ENG')
     self.assertEqual(root.dtprofup, datetime(2005, 1, 1))
     self.assertEqual(root.dtacctup, datetime(2005, 1, 2))
     self.assertIsInstance(root.fi, FI)
     self.assertEqual(root.sesscookie, 'BADA55')
     self.assertEqual(root.accesskey, 'CAFEBABE')
コード例 #46
0
 def testConvert(self):
     # Make sure Aggregate.from_etree() calls Element.convert() and sets
     # Aggregate instance attributes with the result
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INV401KBAL)
     self.assertEqual(instance.cashbal, Decimal("1"))
     self.assertEqual(instance.pretax, Decimal("2"))
     self.assertEqual(instance.aftertax, Decimal("3"))
     self.assertEqual(instance.match, Decimal("4"))
     self.assertEqual(instance.profitsharing, Decimal("5"))
     self.assertEqual(instance.rollover, Decimal("6"))
     self.assertEqual(instance.othervest, Decimal("7"))
     self.assertEqual(instance.othernonvest, Decimal("8"))
     self.assertEqual(instance.total, Decimal("36"))
     self.assertIsInstance(instance.ballist, BALLIST)
コード例 #47
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, SPLIT)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.oldunits, Decimal("200"))
     self.assertEqual(instance.newunits, Decimal("100"))
     self.assertEqual(instance.numerator, Decimal("1"))
     self.assertEqual(instance.denominator, Decimal("2"))
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.fraccash, Decimal("0.50"))
     self.assertEqual(instance.subacctfund, "CASH")
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #48
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertEqual(instance.heldinacct, "MARGIN")
     self.assertEqual(instance.postype, "LONG")
     self.assertEqual(instance.units, Decimal("100"))
     self.assertEqual(instance.unitprice, Decimal("90"))
     self.assertEqual(instance.mktval, Decimal("9000"))
     self.assertEqual(instance.avgcostbasis, Decimal("85"))
     self.assertEqual(instance.dtpriceasof, datetime(2013,
                                                     6,
                                                     30,
                                                     tzinfo=UTC))
     self.assertEqual(instance.memo, "Marked to myth")
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #49
0
 def testConvert(self):
     # Test OOLIST wrapper.  OO members are tested elsewhere.
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INVOOLIST)
     self.assertEqual(len(instance), 11)
     self.assertIsInstance(instance[0], OOBUYDEBT)
     self.assertIsInstance(instance[1], OOBUYMF)
     self.assertIsInstance(instance[2], OOBUYOPT)
     self.assertIsInstance(instance[3], OOBUYOTHER)
     self.assertIsInstance(instance[4], OOBUYSTOCK)
     self.assertIsInstance(instance[5], OOSELLDEBT)
     self.assertIsInstance(instance[6], OOSELLMF)
     self.assertIsInstance(instance[7], OOSELLOPT)
     self.assertIsInstance(instance[8], OOSELLOTHER)
     self.assertIsInstance(instance[9], OOSELLSTOCK)
     self.assertIsInstance(instance[10], SWITCHMF)
コード例 #50
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, CHGUSERINFORQ)
     self.assertEqual(root.firstname, "Mary")
     self.assertEqual(root.middlename, "J.")
     self.assertEqual(root.lastname, "Blige")
     self.assertEqual(root.addr1, "3717 N Clark St")
     self.assertEqual(root.addr2, "Dugout Box, Aisle 19")
     self.assertEqual(root.addr3, "Seat A1")
     self.assertEqual(root.city, "Chicago")
     self.assertEqual(root.state, "IL")
     self.assertEqual(root.postalcode, "60613")
     self.assertEqual(root.country, "USA")
     self.assertEqual(root.dayphone, "(773) 309-1027")
     self.assertEqual(root.evephone, "867-5309")
     self.assertEqual(root.email, "*****@*****.**")
コード例 #51
0
 def testConvertTickerTooLong(self):
     """Don't enforce length restriction on TICKER; raise Warning"""
     # Issue #12
     root = deepcopy(self.etree)
     root[
         2
     ].text = """
     Kekulé dreams the Great Serpent holding its own tail in its mouth, the
     dreaming Serpent which surrounds the World.  But the meanness, the
     cynicism with which this dream is to be used. The Serpent that
     announces, "The World is a closed thing, cyclical, resonant,
     eternally-returning," is to be delivered into a system whose only aim
     is to violate the Cycle. Taking and not giving back, demanding that
     "productivity" and "earnings" keep on increasing with time, the System
     removing from the rest of the World these vast quantities of energy to
     keep its own tiny desperate fraction showing a profit: and not only
     most of humanity — most of the World, animal, vegetable, and mineral,
     is laid waste in the process. The System may or may not understand that
     it's only buying time. And that time is an artificial resource to begin
     with, of no value to anyone or anything but the System, which must
     sooner or later crash to its death, when its addiction to energy has
     become more than the rest of the World can supply, dragging with it
     innocent souls all along the chain of life.
     """
     with self.assertWarns(Warning):
         instance = Aggregate.from_etree(root)
     self.assertEqual(
         instance.ticker,
         """
     Kekulé dreams the Great Serpent holding its own tail in its mouth, the
     dreaming Serpent which surrounds the World.  But the meanness, the
     cynicism with which this dream is to be used. The Serpent that
     announces, "The World is a closed thing, cyclical, resonant,
     eternally-returning," is to be delivered into a system whose only aim
     is to violate the Cycle. Taking and not giving back, demanding that
     "productivity" and "earnings" keep on increasing with time, the System
     removing from the rest of the World these vast quantities of energy to
     keep its own tiny desperate fraction showing a profit: and not only
     most of humanity — most of the World, animal, vegetable, and mineral,
     is laid waste in the process. The System may or may not understand that
     it's only buying time. And that time is an artificial resource to begin
     with, of no value to anyone or anything but the System, which must
     sooner or later crash to its death, when its addiction to energy has
     become more than the rest of the World can supply, dragging with it
     innocent souls all along the chain of life.
     """,
     )
コード例 #52
0
 def testRepr(self):
     instance = Aggregate.from_etree(self.root)
     rep = repr(instance)
     rep_template = ("<OFX fid='{fid}' org='{org}' dtserver='{dtserver}' "
                     "len(statements)={stmtlen} len(securities)={seclen}>")
     # SIGNON values from test_models_signon.FiTestCase
     # DTSERVER from test_models_signon.SonrsTestCase
     # 2 *STMTs each from bank/cc/invstmt (6 total)
     # 5 securitites each from 2 SECLISTs in test_models_securities.SeclistTestCase
     rep_values = {
         "fid": "4705",
         "org": "IBLLC-US",
         "dtserver": datetime(2005, 10, 29, 10, 10, 3, tzinfo=UTC),
         "stmtlen": 6,
         "seclen": 10,
     }
     self.assertEqual(rep, rep_template.format(**rep_values))
コード例 #53
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertEqual(instance.fitid, "1001")
     self.assertEqual(instance.srvrtid, "2002")
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.dtplaced, datetime(2004, 7, 1, tzinfo=UTC))
     self.assertEqual(instance.units, Decimal("150"))
     self.assertEqual(instance.subacct, "CASH")
     self.assertEqual(instance.duration, "GOODTILCANCEL")
     self.assertEqual(instance.restriction, "ALLORNONE")
     self.assertEqual(instance.minunits, Decimal("100"))
     self.assertEqual(instance.limitprice, Decimal("10.50"))
     self.assertEqual(instance.stopprice, Decimal("10.00"))
     self.assertEqual(instance.memo, "Open Order")
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #54
0
 def testConvert(self):
     # Test *TRNRS wrapper and **RS Aggregate.
     # Everything below that is tested elsewhere.
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, CCSTMTRS)
     self.assertEqual(root.curdef, 'USD')
     self.assertIsInstance(root.ccacctfrom, CCACCTFROM)
     self.assertIsInstance(root.banktranlist, BANKTRANLIST)
     self.assertIsInstance(root.ledgerbal, LEDGERBAL)
     self.assertIsInstance(root.availbal, AVAILBAL)
     self.assertEqual(root.cashadvbalamt, Decimal('10000'))
     self.assertEqual(root.intratepurch, Decimal('20.99'))
     self.assertEqual(root.intratecash, Decimal('25.99'))
     self.assertEqual(root.intratexfer, Decimal('21.99'))
     self.assertIsInstance(root.rewardinfo, REWARDINFO)
     self.assertIsInstance(root.ballist, BALLIST)
     self.assertEqual(root.mktginfo, 'Get Free Stuff NOW!!')
コード例 #55
0
    def testFromEtree(self):
        root = ET.Element("TESTAGGREGATE")
        ET.SubElement(root, "METADATA").text = "metadata"
        ET.SubElement(root, "REQ00").text = "Y"
        ET.SubElement(root, "REQ11").text = "N"
        sub = ET.Element("TESTSUBAGGREGATE")
        ET.SubElement(sub, "DATA").text = "data"
        root.append(sub)
        ET.SubElement(root, "DONTUSE").text = "dontuse"

        instance = Aggregate.from_etree(root)
        self.assertIsInstance(instance, TESTAGGREGATE)
        self.assertEqual(instance.metadata, "metadata")
        self.assertEqual(instance.req00, True)
        self.assertEqual(instance.req11, False)
        self.assertIsInstance(instance.testsubaggregate, TESTSUBAGGREGATE)
        self.assertEqual(instance.testsubaggregate.data, "data")
        self.assertIsNone(instance.dontuse)
コード例 #56
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, REINVEST)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.total, Decimal("-161.49"))
     self.assertEqual(instance.incometype, "CGLONG")
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.units, Decimal("100"))
     self.assertEqual(instance.unitprice, Decimal("1.50"))
     self.assertEqual(instance.commission, Decimal("9.99"))
     self.assertEqual(instance.taxes, Decimal("0"))
     self.assertEqual(instance.fees, Decimal("1.50"))
     self.assertEqual(instance.load, Decimal("0"))
     self.assertEqual(instance.taxexempt, True)
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #57
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, TRANSFER)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.units, Decimal("100"))
     self.assertEqual(instance.tferaction, "OUT")
     self.assertEqual(instance.postype, "LONG")
     self.assertIsInstance(instance.invacctfrom, INVACCTFROM)
     self.assertEqual(instance.avgcostbasis, Decimal("22.22"))
     self.assertEqual(instance.unitprice, Decimal("23.01"))
     self.assertEqual(instance.dtpurchase, datetime(1999,
                                                    12,
                                                    31,
                                                    tzinfo=UTC))
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
コード例 #58
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, DEBTINFO)
     self.assertIsInstance(root.secinfo, SECINFO)
     self.assertEqual(root.parvalue, Decimal('1000'))
     self.assertEqual(root.debttype, 'COUPON')
     self.assertEqual(root.debtclass, 'CORPORATE')
     self.assertEqual(root.couponrt, Decimal('5.125'))
     self.assertEqual(root.dtcoupon, datetime(2003, 12, 1, tzinfo=UTC))
     self.assertEqual(root.couponfreq, 'QUARTERLY')
     self.assertEqual(root.callprice, Decimal('1000'))
     self.assertEqual(root.yieldtocall, Decimal('6.5'))
     self.assertEqual(root.dtcall, datetime(2005, 12, 15, tzinfo=UTC))
     self.assertEqual(root.calltype, 'CALL')
     self.assertEqual(root.yieldtomat, Decimal('6.0'))
     self.assertEqual(root.dtmat, datetime(2006, 12, 15, tzinfo=UTC))
     self.assertEqual(root.assetclass, 'INTLBOND')
     self.assertEqual(root.fiassetclass, 'Fixed to floating bond')
コード例 #59
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, CLOSING)
     self.assertEqual(instance.fitid, "DEADBEEF")
     self.assertEqual(instance.dtopen, datetime(2016, 12, 1, tzinfo=UTC))
     self.assertEqual(instance.dtclose, datetime(2016, 12, 25, tzinfo=UTC))
     self.assertEqual(instance.dtnext, datetime(2017, 1, 1, tzinfo=UTC))
     self.assertEqual(instance.balopen, Decimal("11"))
     self.assertEqual(instance.balclose, Decimal("20"))
     self.assertEqual(instance.balmin, Decimal("6"))
     self.assertEqual(instance.depandcredit, Decimal("14"))
     self.assertEqual(instance.chkanddebit, Decimal("-5"))
     self.assertEqual(instance.totalfees, Decimal("0"))
     self.assertEqual(instance.totalint, Decimal("0"))
     self.assertEqual(instance.dtpoststart, datetime(2016, 12, 1, tzinfo=UTC))
     self.assertEqual(instance.dtpostend, datetime(2016, 12, 25, tzinfo=UTC))
     self.assertEqual(instance.mktginfo, "Get Free Stuff NOW!!")
     self.assertIsInstance(instance.currency, CURRENCY)