diff --git a/atst/eda_client.py b/atst/eda_client.py new file mode 100644 index 00000000..09acd859 --- /dev/null +++ b/atst/eda_client.py @@ -0,0 +1,356 @@ +class EDAClientBase(object): + def list_contracts( + self, + contract_number=None, + delivery_order=None, + cage_code=None, + duns_number=None, + ): + """ + Get a list of all contracts matching the given filters. + """ + raise NotImplementedError() + + def get_contract(self, contract_number, status): + """ + Get details for a contract. + """ + raise NotImplementedError() + + +class MockEDAClient(EDAClientBase): + def __init__(self, *args, **kwargs): + pass + + def list_contracts( + self, + contract_number=None, + delivery_order=None, + cage_code=None, + duns_number=None, + ): + return [ + { + "aco_mod": "01", + "admin_dodaac": None, + "cage_code": "1U305", + "contract_no": "DCA10096D0052", + "delivery_order": "0084", + "duns_number": None, + "issue_date": "20000228", + "issue_dodaac": None, + "location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=", + "pay_dodaac": None, + "pco_mod": "02", + }, + { + "aco_mod": "01", + "admin_dodaac": None, + "cage_code": "1U305", + "contract_no": "DCA10096D0052", + "delivery_order": "0084", + "duns_number": None, + "issue_date": "20000228", + "issue_dodaac": None, + "location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=", + "pay_dodaac": None, + "pco_mod": "02", + }, + { + "aco_mod": "01", + "admin_dodaac": None, + "cage_code": "1U305", + "contract_no": "DCA10096D0052", + "delivery_order": "0084", + "duns_number": None, + "issue_date": "20000228", + "issue_dodaac": None, + "location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=", + "pay_dodaac": None, + "pco_mod": "02", + }, + ] + + def get_contract(self, contract_number, status): + if contract_number == "DCA10096D0052" and status == "y": + return { + "aco_mod": "01", + "admin_dodaac": None, + "cage_code": "1U305", + "contract_no": "DCA10096D0052", + "delivery_order": "0084", + "duns_number": None, + "issue_date": "20000228", + "issue_dodaac": None, + "location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=", + "pay_dodaac": None, + "pco_mod": "02", + "amount": 2000000 + } + else: + return None + + +class EDAClient(EDAClientBase): + def __init__(self, base_url, user_name, user_role): + pass + + def list_contracts( + self, + contract_number=None, + delivery_order=None, + cage_code=None, + duns_number=None, + ): + # TODO: Fetch the contracts CSV and transform them into dictionaries. + # https://docs.python.org/3/library/csv.html#csv.DictReader + raise NotImplementedError() + + def get_contract(self, contract_number, status): + # TODO: Fetch the contract XML and transform it into a dictionary. + # https://docs.python.org/3.7/library/xml.etree.elementtree.html + raise NotImplementedError() + + + +CONTRACT_XML = """ + +2.5 +DD 1155 + +3244871 + +00000431 +704331 + + + + + +Department of Defense +Delivery Order +70433119F2644 +Represented Contract + + +Department of Defense +Basic Ordering Agreement +W81K0419G0001 +Ordering Instrument + + +false +Original +false + +Firm Fixed Price + + + + +http://farsite.hill.af.mil/reghtml/regs/far2afmcfars/fardfars/far/52_220.htm#P810_149596 + + +FAR +52.222-50 +Combating Trafficking in Persons. +2015-05 + + + [ lots of text ] + + +
I
+
+ +FAR +52.245-1 +Government Property. +2012-04 + + + [ lots of text ] + + +
I
+
+
+ +2016-02-04 + +2016-01-25 + +DALE WOLFE + +Telephone +520-533-9132 + + + + + +Contractor +
+ +0Z7K0 +808152482 + + +CACI TECHNOLOGIES, INC + + +6933 Gateway Ct +Manassas VA, 20109 + + + +
+
+ +Contract Issuing Office +
+ +704331 + + +FEMA DISTRIBUTION CENTER + + +3870 S. SIDE INDUSTRIAL CTR +ATLANTA GA, 30354 + + + +
+ +GENE BARBER + +Telephone +(202) 646-2727 + + +
+ +Contract Administrative Office +
+ +704331 + + +FEMA DISTRIBUTION CENTER + + +3870 S. SIDE INDUSTRIAL CTR +ATLANTA GA, 30354 + + + +
+
+ +Paying Office +
+ +HQ0131 + + +DEFENSE FINANCE AND ACCOUNTING SVC + + +P.O. BOX 369016 +COLUMBUS OH, 43236 + + + +
+
+ +Ship To +
+ +S0302A + + +DCMA PHOENIX + + +40 NORTH CENTRAL AVE, STE 400 +TWO RENAISSANCE SQUARE +PHOENIX AZ, 85004 + + + +
+
+ + +Header Only - Total Contract Value +192000.00 + + + + +Delivery Requested By + +2016-01-16 + + + + + +Defense Priorities Allocation System (DPAS) Priority Rating + +DO-A7 +
A
+
+ + +Contractor +Origin (after Loading) + + +
+ + + + + +CLIN +0001 + + + + +false + +Cost No Fee + + +Real Property +Radio Dishes +3 +false +Estimated +Each +64000.00 + +Manufacturer's Part Number +5L33M7730291DX081 + + + + + +Estimated Cost +192000.00 + + +Not to Exceed Amount (Funding) +200000.00 + + + + +
+
+""" diff --git a/tests/test_eda_client.py b/tests/test_eda_client.py new file mode 100644 index 00000000..eb1e92d8 --- /dev/null +++ b/tests/test_eda_client.py @@ -0,0 +1,17 @@ +from atst.eda_client import MockEDAClient + + +client = MockEDAClient() + +def test_list_contracts(): + results = client.list_contracts() + assert len(results) == 3 + +def test_get_contract(): + result = client.get_contract("DCA10096D0052", "y") + assert result["contract_no"] == "DCA10096D0052" + assert result["amount"] == 2000000 + +def test_contract_not_found(): + result = client.get_contract("abc", "y") + assert result is None