Bugzilla – Attachment 162802 Details for
Bug 33268
Overlay rules don't work correctly when source is set to *
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33268: Add tests for context module priority
Bug-33268-Add-tests-for-context-module-priority.patch (text/plain), 13.67 KB, created by
Victor Grousset/tuxayo
on 2024-03-05 23:33:55 UTC
(
hide
)
Description:
Bug 33268: Add tests for context module priority
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-03-05 23:33:55 UTC
Size:
13.67 KB
patch
obsolete
>From d3cea63f977948db8359d270be56afbe027a0260 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Thu, 16 Nov 2023 18:24:07 +0100 >Subject: [PATCH] Bug 33268: Add tests for context module priority > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Edit: tidied inline (tcohen) >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Biblio/MarcOverlayRules.t | 189 +++++++++++++++-------- > 1 file changed, 123 insertions(+), 66 deletions(-) > >diff --git a/t/db_dependent/Biblio/MarcOverlayRules.t b/t/db_dependent/Biblio/MarcOverlayRules.t >index 4156907645..1101a7e95d 100755 >--- a/t/db_dependent/Biblio/MarcOverlayRules.t >+++ b/t/db_dependent/Biblio/MarcOverlayRules.t >@@ -66,14 +66,16 @@ my $orig_record = build_record([ > [ '500', 'a', 'One bottle of beer in the fridge' ], > ]); > >-my $incoming_record = build_record([ >- ['250', 'a', '256 bottles of beer on the wall'], # Unchanged >- ['250', 'a', '251 bottles of beer on the wall'], # Appended >- #['250', 'a', '250 bottles of beer on the wall'], # Removed >- #['500', 'a', 'One bottle of beer in the fridge'], # Deleted >- ['501', 'a', 'One cold bottle of beer in the fridge'], # Added >- ['501', 'a', 'Two cold bottles of beer in the fridge'], # Added >-]); >+my $incoming_record = build_record( >+ [ >+ [ '250', 'a', '256 bottles of beer on the wall' ], # Unchanged >+ [ '250', 'a', '251 bottles of beer on the wall' ], # Appended >+ # ['250', 'a', '250 bottles of beer on the wall'], # Removed >+ # ['500', 'a', 'One bottle of beer in the fridge'], # Deleted >+ [ '501', 'a', 'One cold bottle of beer in the fridge' ], # Added >+ [ '501', 'a', 'Two cold bottles of beer in the fridge' ], # Added >+ ] >+); > > # Test default behavior when MARCOverlayRules is enabled, but no rules defined (overwrite) > subtest 'No rule defined' => sub { >@@ -684,14 +686,14 @@ $skip_all_rule->delete(); > > # Test module filter specificity > subtest 'Module filter precedence tests' => sub { >- plan tests => 7; >+ plan tests => 9; > > $rule->set( > { >- tag => '*', >+ tag => '*', > module => 'source', > filter => '*', >- add => 0, >+ add => 0, > append => 0, > remove => 0, > delete => 0, >@@ -700,10 +702,10 @@ subtest 'Module filter precedence tests' => sub { > > my $matching_filter_rule_overwrite = Koha::MarcOverlayRules->find_or_create( > { >- tag => '*', >+ tag => '*', > module => 'source', > filter => 'test', >- add => 1, >+ add => 1, > append => 1, > remove => 1, > delete => 1 >@@ -713,7 +715,7 @@ subtest 'Module filter precedence tests' => sub { > # Current rules: > # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 > # source: test, tag: *, add: 1, append: 1, remove: 1, delete: 1 >- my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > > is( > $merged_record->as_formatted, >@@ -721,16 +723,12 @@ subtest 'Module filter precedence tests' => sub { > 'Non wildcard rule with wildcard tag matches and overrides wildcard rule with wildcard tag' > ); > >- $rule->set( >- { >- tag => '5\d{2}' >- } >- )->store(); >+ $rule->set( { tag => '5\d{2}' } )->store(); > > # Current rules: > # source: *, tag: 5\d{2}, add: 0, append: 0, remove: 0, delete: 0 > # source: test, tag: *, add: 1, append: 1, remove: 1, delete: 1 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > > is( > $merged_record->as_formatted, >@@ -738,16 +736,12 @@ subtest 'Module filter precedence tests' => sub { > 'Non wildcard rule with wildcard tag matches and overrides wildcard rules with regexp tags' > ); > >- $rule->set( >- { >- tag => '501' >- } >- )->store(); >+ $rule->set( { tag => '501' } )->store(); > > # Current rules: > # source: *, tag: 501, add: 0, append: 0, remove: 0, delete: 0 > # source: test, tag: *, add: 1, append: 1, remove: 1, delete: 1 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > > is( > $merged_record->as_formatted, >@@ -755,44 +749,38 @@ subtest 'Module filter precedence tests' => sub { > 'Non wildcard rule with wildcard tag matches and overrides wildcard rules with specific tags' > ); > >- $rule->set( >- { >- tag => '*' >- } >- )->store(); >+ $rule->set( { tag => '*' } )->store(); > > my $wildcard_filter_rule_overwrite = Koha::MarcOverlayRules->find_or_create( > { >- tag => '501', >+ tag => '501', > module => 'source', > filter => '*', >- add => 1, >+ add => 1, > append => 1, > remove => 1, > delete => 1, > } > ); > >- $matching_filter_rule_overwrite->set( >- { >- tag => '250' >- } >- )->store(); >+ $matching_filter_rule_overwrite->set( { tag => '250' } )->store(); > > # Current rules: > # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 > # source: *, tag: 501, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > >- my $expected_record = build_record([ >- ['250', 'a', '256 bottles of beer on the wall'], # Unchanged >- ['250', 'a', '251 bottles of beer on the wall'], # Appended >- #['250', 'a', '250 bottles of beer on the wall'], # Removed >- ['500', 'a', 'One bottle of beer in the fridge'], # Protected >- ['501', 'a', 'One cold bottle of beer in the fridge'], # Added >- ['501', 'a', 'Two cold bottles of beer in the fridge'], # Added >- ]); >+ my $expected_record = build_record( >+ [ >+ [ '250', 'a', '256 bottles of beer on the wall' ], # Unchanged >+ [ '250', 'a', '251 bottles of beer on the wall' ], # Appended >+ #['250', 'a', '250 bottles of beer on the wall'], # Removed >+ [ '500', 'a', 'One bottle of beer in the fridge' ], # Protected >+ [ '501', 'a', 'One cold bottle of beer in the fridge' ], # Added >+ [ '501', 'a', 'Two cold bottles of beer in the fridge' ], # Added >+ ] >+ ); > > is( > $merged_record->as_formatted, >@@ -802,10 +790,10 @@ subtest 'Module filter precedence tests' => sub { > > my $matching_filter_rule_protect = Koha::MarcOverlayRules->find_or_create( > { >- tag => '501', >+ tag => '501', > module => 'source', > filter => 'test', >- add => 0, >+ add => 0, > append => 0, > remove => 0, > delete => 0 >@@ -817,16 +805,18 @@ subtest 'Module filter precedence tests' => sub { > # source: *, tag: 501, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 501, add: 0, append: 0, remove: 0, delete: 0 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > >- $expected_record = build_record([ >- ['250', 'a', '256 bottles of beer on the wall'], # Unchanged >- ['250', 'a', '251 bottles of beer on the wall'], # Appended >- #['250', 'a', '250 bottles of beer on the wall'], # Removed >- ['500', 'a', 'One bottle of beer in the fridge'], # Protected >- #['501', 'a', 'One cold bottle of beer in the fridge'], # Protected >- #['501', 'a', 'Two cold bottles of beer in the fridge'], # Protected >- ]); >+ $expected_record = build_record( >+ [ >+ [ '250', 'a', '256 bottles of beer on the wall' ], # Unchanged >+ [ '250', 'a', '251 bottles of beer on the wall' ], # Appended >+ #['250', 'a', '250 bottles of beer on the wall'], # Removed >+ [ '500', 'a', 'One bottle of beer in the fridge' ], # Protected >+ #['501', 'a', 'One cold bottle of beer in the fridge'], # Protected >+ #['501', 'a', 'Two cold bottles of beer in the fridge'], # Protected >+ ] >+ ); > > is( > $merged_record->as_formatted, >@@ -834,16 +824,18 @@ subtest 'Module filter precedence tests' => sub { > 'Wildcard filter rule has been overridden by non wildcard filter rule with same tag' > ); > >- $matching_filter_rule_protect->set({ >- tag => '5\d{2}', >- })->store(); >+ $matching_filter_rule_protect->set( >+ { >+ tag => '5\d{2}', >+ } >+ )->store(); > > # Current rules: > # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 > # source: *, tag: 501, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 5\d{2}, add: 0, append: 0, remove: 0, delete: 0 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > > is( > $merged_record->as_formatted, >@@ -851,16 +843,18 @@ subtest 'Module filter precedence tests' => sub { > 'Wildcard filter rules with tags that matches tag regexps for non wildcard filter rules has been overridden' > ); > >- $wildcard_filter_rule_overwrite->set({ >- tag => '5\d{2}', >- })->store(); >+ $wildcard_filter_rule_overwrite->set( >+ { >+ tag => '5\d{2}', >+ } >+ )->store(); > > # Current rules: > # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 > # source: *, tag: 5\d{2}, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 > # source: test, tag: 5\d{2}, add: 0, append: 0, remove: 0, delete: 0 >- $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ $merged_record = Koha::MarcOverlayRules->merge_records( $orig_record, $incoming_record, { 'source' => 'test' } ); > > is( > $merged_record->as_formatted, >@@ -868,6 +862,69 @@ subtest 'Module filter precedence tests' => sub { > 'Wildcard filter rules with tags with tag regexps matching the same tag as regexps for non wildcard filter rules has been overridden' > ); > >+ my $categorycode_matching_filter_rule_protect = Koha::MarcOverlayRules->find_or_create( >+ { >+ tag => '*', >+ module => 'categorycode', >+ filter => 'C', >+ add => 0, >+ append => 0, >+ remove => 0, >+ delete => 0 >+ } >+ ); >+ >+ # Current rules: >+ # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 >+ # source: *, tag: 5\d{2}, add: 1, append: 1, remove: 1, delete: 1 >+ # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 >+ # source: test, tag: 5\d{2}, add: 0, append: 0, remove: 0, delete: 0 >+ # categorycode: C, tag: *, add: 0, append: 0, remove: 0, delete: 0 >+ $merged_record = Koha::MarcOverlayRules->merge_records( >+ $orig_record, >+ $incoming_record, >+ { 'source' => 'test', 'categorycode' => 'C' } >+ ); >+ >+ is( >+ $merged_record->as_formatted, >+ $orig_record->as_formatted, >+ 'If both categorycode and source module contexts matches, rules from categorycode module context are used' >+ ); >+ >+ my $userid_matching_filter_rule_protect = Koha::MarcOverlayRules->find_or_create( >+ { >+ tag => '*', >+ module => 'userid', >+ filter => '123', >+ add => 1, >+ append => 1, >+ remove => 1, >+ delete => 1 >+ } >+ ); >+ >+ # Current rules: >+ # source: *, tag: *, add: 0, append: 0, remove: 0, delete: 0 >+ # source: *, tag: 5\d{2}, add: 1, append: 1, remove: 1, delete: 1 >+ # source: test, tag: 250, add: 1, append: 1, remove: 1, delete: 1 >+ # source: test, tag: 5\d{2}, add: 0, append: 0, remove: 0, delete: 0 >+ # categorycode: C, tag: *, add: 0, append: 0, remove: 0, delete: 0 >+ # userid: 123, tag: *, add: 1, append: 1, remove: 1, delete: 1 >+ $merged_record = Koha::MarcOverlayRules->merge_records( >+ $orig_record, >+ $incoming_record, >+ { 'source' => 'test', 'categorycode' => 'C', 'userid' => '123' } >+ ); >+ >+ is( >+ $merged_record->as_formatted, >+ $incoming_record->as_formatted, >+ 'If both userid, categorycode and source module contexts matches, rules from userid module context are used' >+ ); >+ >+ $categorycode_matching_filter_rule_protect->delete(); >+ $userid_matching_filter_rule_protect->delete(); > $wildcard_filter_rule_overwrite->delete(); > $matching_filter_rule_overwrite->delete(); > $matching_filter_rule_protect->delete(); >-- >2.44.0
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 33268
:
158956
|
159004
|
159058
|
159160
|
159161
|
159518
|
159519
|
160017
|
160018
|
162764
|
162766
|
162767
|
162785
|
162786
|
162796
|
162797
|
162798
|
162799
|
162800
|
162801
|
162802
|
162803
|
162804
|
162805
|
162936
|
162937
|
162938
|
162939
|
162940