← all projects

mock-edi

ACME's mock-edi sends an 850 to NORTHWIND's mock-edi, which the capture set to over-ship and to delay its despatch and invoice. Act one: the seller acknowledges the order and confirms the 100 ordered. Act two: the capture moves both clocks an hour, the seller packs and sends a despatch advice for 130, and the buyer's mock reports two problems on it: 130 shipped against 100 confirmed, and against 100 ordered. Act three: the clocks move again, the seller invoices the 130, and the buyer's mock reports that the invoice bills 130 against 100 ordered. The capture delivers each document from one mock to the other, one at a time, and the buyer's mock acknowledges each.
an order that ships too much drawn by mock-films from a real run

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
  • Zero dependencies. Installs in a locked-down CI image.
  • X12 and EDIFACT over AS2. Fixed-width ISA, release characters, HL trees, MDNs with a Received-Content-MIC.
  • It can be the buyer, not only the seller. POST /_mock/purchase places an order with a partner whose role is supplier - so if the system under test is the one that sells, the mock is the customer sending you the 850 and reading your 855, 856 and 810 back, saying where each disagrees with what it ordered. It also receives a remittance advice, the X12 820 and EDIFACT REMADV, and reports one that advises cash before it settles.
  • AS2, plain HTTP, or a folder. Point --drop-dir and --pickup-dir at directories for integrations that still trade files.
  • Changes and receipts. An 860 changes an order and is answered with an 865; EDIFACT's 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. A replayed interchange is refused with a TA1, not fulfilled twice.
  • A backorder is kept. Order 100 of a panel the catalogue holds 35 of, and the line is confirmed with the reason Confirmed 35 of 100; 65 to follow on 2026-10-09, two days on. On that day the balance ships as a second consignment, with a ship notice and an invoice of its own: two payables against one purchase order, and a second invoice that is not the first arriving again. While the balance waits the buyer can still lower or cancel it, even after the first consignment is invoiced.
  • Failure on demand. Short shipments, rejected lines, duplicate invoices, documents out of order, answers an hour late, corrupt trailers, a translator that rejects everything, an invoice that never comes, a strict partner, a partner that never answers.
  • Held to the standards it names. Every X12 segment has the width 004010 gives it and every EDIFACT composite the bounds D.96A gives it, so a correct document in either dialect is not reported against. A name the partner's character set cannot carry is transliterated (Łódź as Lodz, a curled apostrophe as a straight one) rather than written as ?, and one REMADV can replace another, as EANCOM has it.
  • A run you can repeat byte for byte. Start the mock at a chosen time and hold it there, hold the courier and step deliveries one document at a time, and read off the timeline which promise each shipment, invoice and document kept.
  • Validates its own output against the same dictionary it checks yours against.
ACME's order reaches mock-edi, which answers at once and records two promises, a despatch due in an hour and an invoice due in two. The capture set those delays and moves the clock an hour at a time, and each promise fills in when its work appears.
an order that waits for the clock drawn by mock-films from a real run
The capture script asked mock-edi to place an order, and the X12 850 the mock wrote is typed segment by segment from ISA to IEA, each named from the mock's own dictionary, the envelope segments included. The script then altered IEA02, the interchange control number, in a copy and posted the copy to /_mock/validate. Only the altered IEA is typed again, with the mock's refusal beneath it and the wrong number in red.
an 850 opened, and an altered copy refused drawn by mock-films from a real run
BUYERCO's mock-edi sends an 850 to SELLERCO's mock-edi. The capture set the seller to short-ship and to delay its despatch and invoice, so it acknowledges the order, confirms 80 of the 100 ordered, and the buyer's mock flags the shortfall on that 855. The capture delivers each document from one mock to the other, one at a time, and moves both mocks' clocks an hour at a time; the seller then packs and sends the despatch advice, and raises and sends the invoice, with the buyer's mock acknowledging each.
two mocks trading, no script playing a partner drawn by mock-films from a real run
ACME sends mock-edi a purchase order. The mock acknowledges it, answers with an order response, and records two promises, a despatch and an invoice. The capture script then advances the mock's clock: the mock packs the shipment and sends the despatch advice, then raises and sends the invoice, and each promise fills in as its work appears.
an order answered, shipped and billed drawn by mock-films from a real run
ACME is set to EDIFACT and sends mock-edi an ORDERS for the same order as the X12 film. The mock acknowledges it with a CONTRL, answers with an ORDRSP, and records two promises, a despatch and an invoice. The capture script then advances the mock's clock: the mock packs the shipment and sends the DESADV, then raises and sends the INVOIC, and each promise fills in as its work appears.
the same order, in edifact drawn by mock-films from a real run
pip install mock-edi
mock-edi --port 8080
curl -X POST --data-binary @order.edi http://127.0.0.1:8080/edi

Worked examples that use mock-edi: Procure to pay, PO bridge, Invoice check, E-invoice, Pay invoices and Remittance.