From d6ec4a5123e17642434a3b3f0613c9e8fde6caca Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 18 Oct 2018 10:43:44 -0400 Subject: [PATCH] catch type errors for non-floats in CLIN amount field --- atst/eda_client.py | 5 ++++- tests/test_eda_client.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/atst/eda_client.py b/atst/eda_client.py index f4a2f2b6..fe56cd0a 100644 --- a/atst/eda_client.py +++ b/atst/eda_client.py @@ -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: - self.clins[number_el.text] = float(amount_details.text) + try: + self.clins[number_el.text] = float(amount_details.text) + except ValueError: + continue class EDAClientBase(object): diff --git a/tests/test_eda_client.py b/tests/test_eda_client.py index 005e3037..787ba8c8 100644 --- a/tests/test_eda_client.py +++ b/tests/test_eda_client.py @@ -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 = """ + + + + + + + + CLIN + 0001 + + + + + + Not to Exceed Amount (Funding) + not a number + + + + + + +""" + + +def test_eda_xml_parser_with_bad_xml(): + eda_data = parse_eda_xml(_EDA_XML_NO_NUMBER) + assert eda_data["clin_0001"] is None