本文整理汇总了Python中ofxtools.models.base.Aggregate.from_etree方法的典型用法代码示例。如果您正苦于以下问题:Python Aggregate.from_etree方法的具体用法?Python Aggregate.from_etree怎么用?Python Aggregate.from_etree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxtools.models.base.Aggregate
的用法示例。
在下文中一共展示了Aggregate.from_etree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFromEtreeWrongOrder
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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
# 需要导入模块: from ofxtools.models.base import Aggregate [as 别名]
# 或者: from ofxtools.models.base.Aggregate import from_etree [as 别名]
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)