本文整理匯總了Python中ofxtools.models.base.Aggregate類的典型用法代碼示例。如果您正苦於以下問題:Python Aggregate類的具體用法?Python Aggregate怎麽用?Python Aggregate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Aggregate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testFromEtreeWrongOrder
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)
示例2: testMultipleCcacctinfo
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)
示例3: testMultipleInvacctinfo
def testMultipleInvacctinfo(cls):
root = Element("ACCTINFO")
invacctinfo = invest.InvacctinfoTestCase.etree
root.append(invacctinfo)
root.append(invacctinfo)
with cls.assertRaises(ValueError):
Aggregate.from_etree(root)
示例4: testPropertyAliases
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)
示例5: testListItems
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: testListItems
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)
示例7: testFromEtreeMissingRequired
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)
示例8: testOptional
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)
示例9: testRequired
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)
示例10: testListItems
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)
示例11: oneOfTest
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)
示例12: testConvertSecnameTooLong
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.
""")
示例13: testUnsupported
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))
示例14: convert
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
示例15: testFromEtree
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)