Mock enterprise systems for integration testing. Point your code at them and develop, test and demo without a license, a VPN tunnel, or a support ticket.
Using them together: Testing an SAP-to-EDI integration without SAP or a trading partner.
A black-box mock SAP endpoint. It speaks the shapes, not the business logic: SAP Gateway OData V2 and V4 services, BAPI/RFC calls over JSON and SOAP, and IDocs in XML and flat-file form, all backed by SQLite.
__metadata, /Date(…)/, EDMX $metadata, CSRF tokens, $batch changesets, BAPIRET2 tables.$apply aggregation, delta tokens, Fiori UI annotations, and OAuth 2.0 token flows a client can expire and refresh.pip install mock-sap
mock-sap --port 8000
curl "http://127.0.0.1:8000/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder?\$top=1&\$format=json"
A mock EDI trading partner. Not an EDI library or an AS2 server, but the thing on the other end. Send it an 850 and it answers with a 997, an 855, an 856 and an 810. Send it EDIFACT ORDERS and you get CONTRL, ORDRSP, DESADV and INVOIC.
you ──850──▶ mock-edi
◀──997── the syntax parsed
◀──855── 2 lines: one confirmed, one short
◀──856── shipment / order / item, with a tracking number
◀──810── 1132.80, terms 2% 10 net 30
HL trees, MDNs with a Received-Content-MIC.--drop-dir and --pickup-dir at directories for integrations that still trade files.ORDCHG is answered by an ORDRSP, having no change acknowledgment of its own. The 997s you send back are matched to what the mock sent, so "nobody acknowledged my invoice" is testable.pip install mock-edi
mock-edi --port 8080
curl -X POST --data-binary @order.edi http://127.0.0.1:8080/edi
A worked example of the two mocks together. po_bridge.py reads a purchase order from SAP over OData, sends it to the supplier as an X12 850, and posts the supplier's 855 back into SAP as an ORDRSP IDoc. Any line that isn't a clean confirmation comes back as an exception for a buyer to look at.
send: SAP PO (OData) ──▶ X12 850 ──▶ supplier
receive: SAP ◀── ORDRSP IDoc ◀── X12 855 ◀── supplier
git clone https://github.com/rseufert/mock-edi && cd mock-edi
pip install mock-sap
mock-sap --port 8000 &
python3 -m mockedi --port 8080 &
cd examples && python3 -m unittest -v test_po_bridge
What happens after the goods ship. invoice_check.py is accounts-payable middleware: it takes a supplier's X12 810 invoice and posts it into SAP as an INVOIC IDoc only if it passes a three-way match against the purchase order and the 856 ship notice. Anything else is blocked, with the reasons.
PO (SAP) ──┐
856 ship ──┼──▶ match? ──▶ yes: INVOIC IDoc into SAP
810 bill ──┘ no: blocked, with reasons
git clone https://github.com/rseufert/mock-sap && cd mock-sap
pip install mock-edi
python3 -m mocksap --port 8000 &
mock-edi --port 8080 &
cd examples && python3 -m unittest -v test_invoice_check