Example #1
0
    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)
Example #2
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)
 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)
Example #4
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)
Example #5
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)
Example #6
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)
Example #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)
Example #8
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)
Example #9
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)
Example #10
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)
Example #11
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)
Example #12
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)
Example #13
0
    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)
Example #14
0
 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)
Example #15
0
 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)
Example #16
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)
    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)
Example #18
0
    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)
Example #19
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)
Example #20
0
    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)
Example #21
0
 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))
 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)
 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.
     """)
 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)
Example #25
0
 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
Example #26
0
    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)
 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)
Example #28
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)
 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)
 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)
Example #31
0
 def aggregate(cls):
     return PROFRS(
         msgsetlist=Aggregate.from_etree(cls.msgsetlist),
         signoninfolist=SignoninfolistTestCase.aggregate,
         dtprofup=datetime(2001, 4, 1, tzinfo=UTC),
         finame="Dewey Cheatham & Howe",
         addr1="3717 N Clark St",
         addr2="Dugout Box, Aisle 19",
         addr3="Seat A1",
         city="Chicago",
         state="IL",
         postalcode="60613",
         country="USA",
         csphone="(773) 309-1027",
         tsphone="(773) 309-1028",
         faxphone="(773) 309-1029",
         url="http://www.ameritrade.com",
         email="*****@*****.**",
     )
Example #32
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, SONRQ)
     self.assertEqual(root.dtclient,
                      datetime(2005, 10, 29, 10, 10, 3, tzinfo=UTC))
     self.assertEqual(root.userkey, "DEADBEEF")
     self.assertEqual(root.genuserkey, False)
     self.assertEqual(root.language, "ENG")
     self.assertIsInstance(root.fi, FI)
     self.assertEqual(root.sesscookie, "BADA55")
     self.assertEqual(root.appid, "QWIN")
     self.assertEqual(root.appver, "1500")
     self.assertEqual(root.clientuid, "DEADBEEF")
     self.assertEqual(root.usercred1, "Something")
     self.assertEqual(root.usercred2, "Something else")
     self.assertEqual(root.authtoken, "line noise")
     self.assertEqual(root.accesskey, "CAFEBABE")
Example #33
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, SONRQ)
     self.assertEqual(root.dtclient,
                      datetime(2005, 10, 29, 10, 10, 3, tzinfo=UTC))
     self.assertEqual(root.userkey, 'DEADBEEF')
     self.assertEqual(root.genuserkey, False)
     self.assertEqual(root.language, 'ENG')
     self.assertIsInstance(root.fi, FI)
     self.assertEqual(root.sesscookie, 'BADA55')
     self.assertEqual(root.appid, 'QWIN')
     self.assertEqual(root.appver, '1500')
     self.assertEqual(root.clientuid, 'DEADBEEF')
     self.assertEqual(root.usercred1, 'Something')
     self.assertEqual(root.usercred2, 'Something else')
     self.assertEqual(root.authtoken, 'line noise')
     self.assertEqual(root.accesskey, 'CAFEBABE')
Example #34
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, PROFRS)
     self.assertIsInstance(root.msgsetlist, MSGSETLIST)
     self.assertIsInstance(root.signoninfolist, SIGNONINFOLIST)
     self.assertEqual(root.dtprofup, datetime(2001, 4, 1, tzinfo=UTC))
     self.assertEqual(root.finame, 'Dewey Cheatham & Howe')
     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.csphone, '(773) 309-1027')
     self.assertEqual(root.tsphone, '(773) 309-1028')
     self.assertEqual(root.faxphone, '(773) 309-1029')
     self.assertEqual(root.url, 'http://www.ameritrade.com')
     self.assertEqual(root.email, '*****@*****.**')
Example #35
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, PROFRS)
     self.assertIsInstance(root.msgsetlist, MSGSETLIST)
     self.assertIsInstance(root.signoninfolist, SIGNONINFOLIST)
     self.assertEqual(root.dtprofup, datetime(2001, 4, 1, tzinfo=UTC))
     self.assertEqual(root.finame, "Dewey Cheatham & Howe")
     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.csphone, "(773) 309-1027")
     self.assertEqual(root.tsphone, "(773) 309-1028")
     self.assertEqual(root.faxphone, "(773) 309-1029")
     self.assertEqual(root.url, "http://www.ameritrade.com")
     self.assertEqual(root.email, "*****@*****.**")
Example #36
0
    def testConvert(self):
        instance = Aggregate.from_etree(self.root)
        self.assertIsInstance(instance, ENROLLRQ)
        self.assertEqual(instance.firstname, "Porky")
        self.assertEqual(instance.middlename, "D.")
        self.assertEqual(instance.lastname, "Pig")
        self.assertEqual(instance.addr1, "3717 N Clark St")
        self.assertEqual(instance.addr2, "Dugout Box, Aisle 19")
        self.assertEqual(instance.addr3, "Seat A1")
        self.assertEqual(instance.city, "Chicago")
        self.assertEqual(instance.state, "IL")
        self.assertEqual(instance.postalcode, "60613")
        self.assertEqual(instance.country, "USA")
        self.assertEqual(instance.dayphone, "(773) 309-1027")
        self.assertEqual(instance.evephone, "867-5309")
        self.assertEqual(instance.userid, "bacon2b")
        self.assertEqual(instance.taxid, "123456789")
        self.assertEqual(instance.securityname, "Petunia")
        self.assertEqual(instance.datebirth, datetime(2016, 7, 5, tzinfo=UTC))

        return instance
Example #37
0
    def testConvertRemoveProprietaryTag(cls):
        # Make sure SONRS.from_etree() removes proprietary tags
        root = deepcopy(cls.etree)
        SubElement(root, "INTU.BANKID").text = "12345678"

        sonrs = Aggregate.from_etree(root)
        cls.assertIsInstance(sonrs, SONRS)
        # Converted Aggregate should still have 10 values, not 11
        cls.assertEqual(len(sonrs._spec_repr), 10)

        cls.assertIsInstance(sonrs.status, STATUS)
        cls.assertEqual(sonrs.dtserver,
                        datetime(2005, 10, 29, 10, 10, 3, tzinfo=UTC))
        cls.assertEqual(sonrs.userkey, "DEADBEEF")
        cls.assertEqual(sonrs.tskeyexpire, datetime(2005, 12, 31, tzinfo=UTC))
        cls.assertEqual(sonrs.language, "ENG")
        cls.assertEqual(sonrs.dtprofup, datetime(2005, 1, 1, tzinfo=UTC))
        cls.assertEqual(sonrs.dtacctup, datetime(2005, 1, 2, tzinfo=UTC))
        cls.assertIsInstance(sonrs.fi, FI)
        cls.assertEqual(sonrs.sesscookie, "BADA55")
        cls.assertEqual(sonrs.accesskey, "CAFEBABE")
Example #38
0
    def testMixedSvcxxx(self):
        svcadd = SvcaddBankTestCase().root
        svcchg = SvcchgBankTestCase().root
        svcdel = SvcdelBankTestCase().root

        root = Element("ACCTRS")
        root.append(svcadd)
        root.append(svcchg)
        SubElement(root, "SVC").text = "BANKSVC"
        SubElement(root, "SVCSTATUS").text = "AVAIL"
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("ACCTRS")
        root.append(svcadd)
        root.append(svcdel)
        SubElement(root, "SVC").text = "BANKSVC"
        SubElement(root, "SVCSTATUS").text = "AVAIL"
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("ACCTRS")
        root.append(svcchg)
        root.append(svcdel)
        SubElement(root, "SVC").text = "BANKSVC"
        SubElement(root, "SVCSTATUS").text = "AVAIL"
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("ACCTRS")
        root.append(svcadd)
        root.append(svcchg)
        root.append(svcdel)
        SubElement(root, "SVC").text = "BANKSVC"
        SubElement(root, "SVCSTATUS").text = "AVAIL"
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
Example #39
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.units, Decimal("100"))
     self.assertEqual(instance.unitprice, Decimal("1.50"))
     self.assertEqual(instance.markup, Decimal("0"))
     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.total, Decimal("-161.49"))
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.subacctfund, "CASH")
     self.assertEqual(instance.loanid, "1")
     self.assertEqual(instance.loanprincipal, Decimal("1.50"))
     self.assertEqual(instance.loaninterest, Decimal("3.50"))
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     self.assertEqual(instance.dtpayroll, datetime(2004, 6, 15, tzinfo=UTC))
     self.assertEqual(instance.prioryearcontrib, True)
     return instance
Example #40
0
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, STMTTRN)
     self.assertEqual(root.trntype, 'CHECK')
     self.assertEqual(root.dtposted, datetime(2013, 6, 15))
     self.assertEqual(root.dtuser, datetime(2013, 6, 14))
     self.assertEqual(root.dtavail, datetime(2013, 6, 16))
     self.assertEqual(root.trnamt, Decimal('-433.25'))
     self.assertEqual(root.fitid, 'DEADBEEF')
     self.assertEqual(root.correctfitid, 'B00B5')
     self.assertEqual(root.correctaction, 'REPLACE')
     self.assertEqual(root.srvrtid, '101A2')
     self.assertEqual(root.checknum, '101')
     self.assertEqual(root.refnum, '5A6B')
     self.assertEqual(root.sic, 171103)
     self.assertEqual(root.payeeid, '77810')
     self.assertEqual(root.name, 'Tweet E. Bird')
     self.assertEqual(root.extdname, 'Singing yellow canary')
     self.assertEqual(root.memo, 'Protection money')
     self.assertIsInstance(root.origcurrency, ORIGCURRENCY)
     self.assertEqual(root.inv401ksource, 'PROFITSHARING')
     return root
Example #41
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance.invtran, INVTRAN)
     self.assertIsInstance(instance.secid, SECID)
     self.assertEqual(instance.units, Decimal("-100"))
     self.assertEqual(instance.unitprice, Decimal("1.50"))
     self.assertEqual(instance.markdown, Decimal("0"))
     self.assertEqual(instance.commission, Decimal("9.99"))
     self.assertEqual(instance.taxes, Decimal("2"))
     self.assertEqual(instance.fees, Decimal("1.50"))
     self.assertEqual(instance.load, Decimal("0"))
     self.assertEqual(instance.withholding, Decimal("3"))
     self.assertEqual(instance.taxexempt, False)
     self.assertEqual(instance.total, Decimal("131"))
     self.assertEqual(instance.gain, Decimal("3.47"))
     self.assertIsInstance(instance.currency, CURRENCY)
     self.assertEqual(instance.subacctsec, "MARGIN")
     self.assertEqual(instance.subacctfund, "CASH")
     self.assertEqual(instance.loanid, "1")
     self.assertEqual(instance.statewithholding, Decimal("2.50"))
     self.assertEqual(instance.penalty, Decimal("0.01"))
     self.assertEqual(instance.inv401ksource, "PROFITSHARING")
     return instance
Example #42
0
    def testMixedXxxacctfrom(self):
        bankacctfrom = BankacctfromTestCase().root
        ccacctfrom = CcacctfromTestCase().root
        invacctfrom = InvacctfromTestCase().root

        root = Element("SVCDEL")
        root.append(bankacctfrom)
        root.append(ccacctfrom)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("SVCDEL")
        root.append(bankacctfrom)
        root.append(invacctfrom)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)

        root = Element("SVCDEL")
        root.append(bankacctfrom)
        root.append(invacctfrom)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
Example #43
0
    def testMixedXxxacctto(self):
        bankacctto = BankaccttoTestCase().root
        ccacctto = CcaccttoTestCase().root
        invacctto = InvaccttoTestCase().root

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

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

        root = Element("SVCADD")
        root.append(bankacctto)
        root.append(invacctto)
        with self.assertRaises(ValueError):
            Aggregate.from_etree(root)
Example #44
0
 def testValidSoup(self):
     for etree in self.validSoup:
         Aggregate.from_etree(etree)
Example #45
0
 def testUnsupported(self):
     instance = Aggregate.from_etree(self.etree)
     for unsupp in self.unsupported:
         setattr(instance, unsupp, "FOOBAR")
         self.assertIsNone(getattr(instance, unsupp))
Example #46
0
 def testFromEtree(self):
     self._eqAggregate(self.aggregate, Aggregate.from_etree(self.etree))
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, BPACCTINFO)
     self.assertIsInstance(root.bankacctfrom, BANKACCTFROM)
     self.assertEqual(root.svcstatus, "AVAIL")
 def testInvalidSoup(self):
     for root in self.invalidSoup:
         with self.assertRaises(ValueError):
             Aggregate.from_etree(root)
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, EXTDPMTINV)
     self.assertEqual(len(root), 2)
     for item in root:
         self.assertIsInstance(item, INVOICE)
Example #50
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, INVBANKTRAN)
     self.assertIsInstance(instance.stmttrn, STMTTRN)
     self.assertEqual(instance.subacctfund, "MARGIN")
Example #51
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, BUYSTOCK)
     self.assertIsInstance(instance.invbuy, INVBUY)
     self.assertEqual(instance.buytype, "BUYTOCOVER")
Example #52
0
 def testExtraElement(self):
     etree = deepcopy(self.etree)
     ET.SubElement(etree, "FAKEELEMENT").text = "garbage"
     with self.assertRaises(ValueError):
         Aggregate.from_etree(etree)
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, LINEITEM)
     self.assertEqual(root.litmamt, Decimal("13.5"))
     self.assertEqual(root.litmdesc, "Purchase Item")
Example #54
0
 def testPropertyAliases(self):
     instance = Aggregate.from_etree(self.root)
     self.assertEqual(instance.fitid, instance.invtran.fitid)
     self.assertEqual(instance.dttrade, instance.invtran.dttrade)
     self.assertEqual(instance.memo, instance.invtran.memo)
 def testValidSoup(self):
     for root in self.validSoup:
         Aggregate.from_etree(root)
Example #56
0
 def testConvert(self):
     instance = Aggregate.from_etree(self.root)
     self.assertIsInstance(instance, SELLDEBT)
     self.assertIsInstance(instance.invsell, INVSELL)
     self.assertEqual(instance.sellreason, "MATURITY")
     self.assertEqual(instance.accrdint, Decimal("25.50"))
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, PMTPRCSTS)
     self.assertEqual(root.pmtprccode, "FAILEDON")
     self.assertEqual(root.dtpmtprc, datetime(2001, 1, 1, tzinfo=UTC))
Example #58
0
 def testPropertyAliases(cls):
     instance = Aggregate.from_etree(cls.etree)
     cls.assertIs(instance.account, instance.invacctfrom)
     cls.assertIs(instance.balances, instance.invbal)
     cls.assertIs(instance.transactions, instance.invtranlist)
     cls.assertIs(instance.positions, instance.invposlist)
 def testConvert(self):
     root = Aggregate.from_etree(self.root)
     self.assertIsInstance(root, BILLPUBINFO)
     self.assertEqual(root.billpub, "Pubco")
     self.assertEqual(root.billid, "54321")
Example #60
0
 def testPropertyAliases(cls):
     instance = Aggregate.from_etree(cls.etree)
     stmt = instance.statement
     cls.assertIsInstance(stmt, INVSTMTRS)