Bugzilla – Attachment 176180 Details for
Bug 38689
EDIFACT errors should log to a staff accessible location
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38689: Add logging tests for process_quote
Bug-38689-Add-logging-tests-for-processquote.patch (text/plain), 6.57 KB, created by
Martin Renvoize (ashimema)
on 2025-01-07 11:23:21 UTC
(
hide
)
Description:
Bug 38689: Add logging tests for process_quote
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-01-07 11:23:21 UTC
Size:
6.57 KB
patch
obsolete
>From 5bd0ea0721b895fb880fd4f4dd2b747710ca1381 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 3 Jan 2025 16:32:12 +0000 >Subject: [PATCH] Bug 38689: Add logging tests for process_quote > >This adds missing tests for the Koha::Logger based logging of messages >in the process_quote process. We also tidy up the log lines a tiny bit >for consistency. >--- > Koha/EDI.pm | 10 +++--- > t/db_dependent/Koha/EDI.t | 70 ++++++++++++++++++++++++++++++++++----- > 2 files changed, 67 insertions(+), 13 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 04c6365a66b..82708596018 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -308,7 +308,7 @@ sub process_invoice { > } > ); > my $invoiceid = $new_invoice->invoiceid; >- $logger->trace("Added as invoiceno :$invoiceid"); >+ $logger->trace("Added as invoiceno: $invoiceid"); > my $lines = $msg->lineitems(); > > foreach my $line ( @{$lines} ) { >@@ -477,7 +477,7 @@ sub receipt_items { > } > ); > $logger->warn( >- "Cannot find aqorder item for $i :Order:$ordernumber"); >+ "Cannot find aqorder item for $i: Order: $ordernumber"); > next; > } > my $b = $item->get_column('homebranch'); >@@ -650,7 +650,7 @@ sub process_quote { > } else { > $quote_message->basketno($basketno); > } >- $logger->trace("Created basket :$basketno"); >+ $logger->trace("Created basket: $basketno"); > my $items = $msg->lineitems(); > my $refnum = $msg->message_refno; > >@@ -859,7 +859,7 @@ sub quote_item { > $order_hash->{budget_id} = $budget->budget_id; > my $first_order = $schema->resultset('Aqorder')->create($order_hash); > my $o = $first_order->ordernumber(); >- $logger->trace("Order created :$o"); >+ $logger->trace("Order created: $o"); > > # should be done by database settings > $first_order->parent_ordernumber( $first_order->ordernumber() ); >@@ -946,7 +946,7 @@ sub quote_item { > my $new_order = > $schema->resultset('Aqorder')->create($order_hash); > my $o = $new_order->ordernumber(); >- $logger->trace("Order created :$o"); >+ $logger->trace("Order created: $o"); > > # should be done by database settings > $new_order->parent_ordernumber( $new_order->ordernumber() ); >diff --git a/t/db_dependent/Koha/EDI.t b/t/db_dependent/Koha/EDI.t >index 762ea2e88dc..6a249ec3422 100755 >--- a/t/db_dependent/Koha/EDI.t >+++ b/t/db_dependent/Koha/EDI.t >@@ -36,7 +36,7 @@ my $builder = t::lib::TestBuilder->new; > my $logger = t::lib::Mocks::Logger->new(); > > subtest 'process_quote' => sub { >- plan tests => 7; >+ plan tests => 16; > > $schema->storage->txn_begin; > >@@ -93,11 +93,45 @@ subtest 'process_quote' => sub { > } > ); > >+ t::lib::Mocks::mock_preference( 'CataloguingLog', 0 ); >+ > # Process the test quote file >- process_quote($quote); >+ my $error; >+ eval { >+ process_quote($quote); >+ 1; >+ } or do { >+ $error = $@; >+ }; >+ ok( !$error, 'process_quote completed without dying' ); > > # Test for expected warnings for the passed quote file >- # >+ is( $logger->count, 8, "8 log lines recorded for passed quote file" ); >+ #$logger->diag(); >+ $logger->trace_like( >+ qr/Created basket:.*/, >+ "Trace recorded adding basket" >+ )->trace_like( >+ qr/Checking db for matches.*/, >+ "Trace recorded checking db for matches" >+ )->trace_like( >+ qr/New biblio added.*/, >+ "Trace recoded adding new biblio" >+ )->trace_like( >+ qr/Order created:.*/, >+ "Trace recorded adding order" >+ )->trace_like( >+ qr/Added item:.*/, >+ "Trace recorded adding new item" >+ )->trace_like( >+ qr/Item added to rota.*/, >+ "Trace recrded adding item to rota" >+ )->debug_like( >+ qr/.*specialUpdate biblioserver$/, >+ "Trace recorded biblioserver index" >+ ) >+ ->clear(); >+ > # Test for quote status change > $quote->get_from_storage; > is( $quote->status, 'received', 'Quote status was set to received' ); >@@ -294,7 +328,7 @@ subtest '_handle_008_field' => sub { > }; > > subtest 'process_invoice' => sub { >- plan tests => 12; >+ plan tests => 19; > > $schema->storage->txn_begin; > >@@ -372,6 +406,8 @@ subtest 'process_invoice' => sub { > }; > ok( !$error, 'process_invoice completed without dying' ); > >+ is( $logger->count, 14, "14 log lines recorded for passed invoice file" ); >+ #$logger->diag(); > $logger->trace_like( > qr/Adding invoice:.*/, > "Trace recorded adding invoice" >@@ -380,22 +416,40 @@ subtest 'process_invoice' => sub { > "Trace recorded invoice added" > )->error_is( > 'Skipping invoice line, no associated ordernumber', >- "Received expected log line for missing ordernumber line" >+ "Error recorded for missing ordernumber line" > )->error_like( > qr/Skipping invoice line, no order found for.*/, >- 'Received expected log line for unmatched ordernumber line' >+ 'Error recorded for unmatched ordernumber line' > )->error_like( > qr/Skipping invoice line, no bibliographic.*/, >- 'Received expected log line for unmatched biblionumber line' >+ 'Error recorded for unmatched biblionumber line' > )->trace_like( > qr/Receipting order:.*/, > 'Trace recorded invoice receipted' > )->trace_like( > qr/Updating bib:.*/, > 'Trace recorded bib updated' >+ )->trace_like( >+ qr/Receipting order:.*/, >+ 'Trace recorded invoice receipted - Check why this happens a second time' >+ )->trace_like( >+ qr/Updating bib:.*/, >+ 'Trace recorded bib updated - same bib, different id' > )->error_like( > qr/Cannot find vendor with ean.*/, >- 'Received expected log line for missing ean' >+ 'Error recorded for missing ean' >+ )->warn_like( >+ qr/transferring.*/, >+ 'Warn recorded for transfering items' >+ )->warn_like( >+ qr/Unmatched item at branch:.*/, >+ 'Warn recorded for unmatched item' >+ )->warn_like( >+ qr/transferring.*/, >+ 'Warn recorded for transfering items' >+ )->warn_like( >+ qr/Unmatched item at branch:.*/, >+ 'Warn recorded for unmatched item' > )->clear(); > > my $invoice3 = Koha::Acquisition::Invoices->search( { invoicenumber => 'INV00003' }, { rows => 1 } )->single; >-- >2.47.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38689
:
175788
|
175789
|
175790
|
175793
|
175794
|
175795
|
175796
|
175797
|
175809
|
175810
|
175811
|
175812
|
175813
|
175814
|
175815
|
175816
|
175817
|
176127
|
176128
|
176129
|
176130
|
176131
|
176132
|
176133
|
176134
|
176173
|
176174
|
176175
|
176176
|
176177
|
176178
|
176179
|
176180
|
176181
|
176182
|
176183
|
176373
|
176374
|
176375
|
176376
|
176377
|
176378
|
176379
|
176380
|
176381
|
176382
|
176524
|
176525
|
176526
|
176527
|
176528
|
176529
|
176530
|
176531
|
176532
|
176533
|
176605
|
176606
|
176607
|
176608
|
176609
|
176610
|
176611
|
176612
|
176613
|
176614