From da0e65f799c5540e4b60517c9f69eaefc8c46365 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 6 Dec 2021 14:12:21 -0500 Subject: [PATCH] LP1952931 ASN shipment notifiation Perl Test Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t | 102 ++++++++++++++++++-------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t b/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t index d5e246a22a..fcf8b0cd5a 100755 --- a/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t +++ b/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t @@ -3,6 +3,7 @@ use strict; use warnings; use OpenILS::Utils::TestUtils; use OpenILS::Utils::CStoreEditor (':funcs'); use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::Acq::EDI; use Test::More tests => 5; @@ -22,10 +23,26 @@ use constant { ADMIN_PASS => 'demo123' }; +# Stub MARC with an ISBN as an order identifier +my $LI_MARC = < + a + + 9780307887436 + + +MARC + my $U = 'OpenILS::Application::AppUtils'; my $script = OpenILS::Utils::TestUtils->new(); $script->bootstrap; +my $po_id; +my $li_id; +my $edi_account; my $e = new_editor; $e->init; @@ -38,8 +55,11 @@ $script->authenticate({ BAIL_OUT('Failed to Login') unless $script->authtoken; sub main { + $e->xact_begin; create_seed_data(); - process_asn(create_po()); + create_po(); + BAIL_OUT("Failed to commit transaction") unless $e->commit; + process_asn(); } @@ -51,13 +71,13 @@ sub create_seed_data { BAIL_OUT("Could not apply SAN to BR1 " . $e->die_event) unless $e->update_actor_org_address($addr); - my $acct = Fieldmapper::acq::edi_account->new; - $acct->provider(PROVIDER_ID); - $acct->host("example.org"); - $acct->label("ASN TEST"); + $edi_account = Fieldmapper::acq::edi_account->new; + $edi_account->provider(PROVIDER_ID); + $edi_account->host("example.org"); + $edi_account->label("ASN TEST"); BAIL_OUT("Could not create EDI account " . $e->die_event) - unless $e->create_acq_edi_account($acct); + unless $e->create_acq_edi_account($edi_account); } sub create_po { @@ -71,11 +91,13 @@ sub create_po { 'open-ils.acq.purchase_order.create', $script->authtoken, $po); BAIL_OUT("Failed to create PO: $resp") if $U->is_event($resp); + + $po_id = $resp->purchase_order->id; my $li = Fieldmapper::acq::lineitem->new; - $li->purchase_order($resp->purchase_order->id); + $li->purchase_order($po_id); $li->eg_bib_id(BIB_ID); - $li->marc(' a 9780307887436'); + $li->marc($LI_MARC); $li->creator(ADMIN_ID); $li->editor(ADMIN_ID); $li->selector(ADMIN_ID); @@ -98,37 +120,53 @@ sub create_po { BAIL_OUT("Failed to create Lineitem Detail: $resp") if $U->is_event($resp); - return $$resp->purchase_order->id; + my $attr = $e->search_acq_lineitem_marc_attr_definition({ + lineitem => $li_id, attr_name => 'isbn'})->[0]; + + BAIL_OUT("Lineitem creation did not create an ISBN attribute") + unless $attr; + + $attr->order_ident('t'); + + BAIL_OUT("Failed apply order_ident to ISBN attr: " . $e->die_event) + unless $e->update_acq_lineitem_marc_attr_definition($attr); } sub process_asn { - my $po_id = shift; my $ASN = <process_retrieval( + $ASN, "remote-file-name", + OpenILS::Application::Acq::EDI->remote_account($edi_account), + $edi_acctount + ); + + # TODO test presence of shipment notification and entry + } main(); -- 2.11.0