catch type errors for non-floats in CLIN amount field

This commit is contained in:
dandds 2018-10-18 10:43:44 -04:00
parent af81cd1da7
commit d6ec4a5123
2 changed files with 35 additions and 1 deletions

View File

@ -35,7 +35,10 @@ class EDAXMLHandler:
".//ItemOtherAmounts[AmountDescription='Not to Exceed Amount (Funding)']/Amount"
)
if number_el is not None and amount_details is not None:
try:
self.clins[number_el.text] = float(amount_details.text)
except ValueError:
continue
class EDAClientBase(object):

View File

@ -24,3 +24,34 @@ def test_eda_xml_parser():
eda_data = parse_eda_xml(contract.read())
assert eda_data["clin_0001"] == 200_000.00
assert not eda_data["clin_0003"]
_EDA_XML_NO_NUMBER = """
<ProcurementDocument>
<AwardInstrument>
<ContractLineItems>
<LineItems>
<LineItemIdentifier>
<DFARS>
<LineItem>
<LineItemType>CLIN</LineItemType>
<LineItemBase>0001</LineItemBase>
</LineItem>
</DFARS>
</LineItemIdentifier>
<LineItemAmounts>
<ItemOtherAmounts>
<AmountDescription>Not to Exceed Amount (Funding)</AmountDescription>
<Amount>not a number</Amount>
</ItemOtherAmounts>
</LineItemAmounts>
</LineItems>
</ContractLineItems>
</AwardInstrument>
</ProcurementDocument>
"""
def test_eda_xml_parser_with_bad_xml():
eda_data = parse_eda_xml(_EDA_XML_NO_NUMBER)
assert eda_data["clin_0001"] is None