Bug 25113

Summary: Make CirculationRules.t flexible for new scope combinations
Product: Koha Reporter: Lari Taskula <lari.taskula>
Component: Test SuiteAssignee: Lari Taskula <lari.taskula>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: joonas.kylmala, lari.taskula, lucas
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00
Bug Depends on:    
Bug Blocks: 25089    
Attachments: Bug 25113: Refactor CirculationRules.t when testing scope combinations
Bug 25113: Refactor CirculationRules.t when testing scope combinations
Bug 25113: Refactor CirculationRules.t when testing scope combinations
Bug 25113: Refactor CirculationRules.t when testing scope combinations
Bug 25113: Refactor CirculationRules.t when testing scope combinations

Description Lari Taskula 2020-04-11 19:54:47 UTC
We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

Remove those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.
Comment 1 Lari Taskula 2020-04-11 19:58:11 UTC
Created attachment 102765 [details] [review]
Bug 25113: Refactor CirculationRules.t when testing scope combinations

We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

This patch removes those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.

This also obsoletes the "Get effective issuing rule in correct order"
test in t/db_dependent/Koha/IssuingRules.t

To test:
1. prove t/db_dependent/Koha/CirculationRules.t

Sponsored-by: The National Library of Finland
Comment 2 Lari Taskula 2020-04-21 10:42:56 UTC
Created attachment 103350 [details] [review]
Bug 25113: Refactor CirculationRules.t when testing scope combinations

We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

This patch removes those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.

This also obsoletes the "Get effective issuing rule in correct order"
test in t/db_dependent/Koha/IssuingRules.t

To test:
1. prove t/db_dependent/Koha/CirculationRules.t

Sponsored-by: The National Library of Finland
Comment 3 Joonas Kylmälä 2020-06-12 10:19:43 UTC
In the patch you mention

> This also obsoletes the "Get effective issuing rule in correct order"
> test in t/db_dependent/Koha/IssuingRules.t

why is it obsoleted?
Comment 4 Lari Taskula 2020-07-07 10:45:42 UTC
(In reply to Joonas Kylmälä from comment #3)
> In the patch you mention
> 
> > This also obsoletes the "Get effective issuing rule in correct order"
> > test in t/db_dependent/Koha/IssuingRules.t
> 
> why is it obsole(In reply to Joonas Kylmälä from comment #3)
> In the patch you mention
> 
> > This also obsoletes the "Get effective issuing rule in correct order"
> > test in t/db_dependent/Koha/IssuingRules.t
> 
> why is it obsoleted?

It is the test I refer to in the original post of this Bug.

> We used to test rule scopes by explicitly defining each combination.
> When adding new scopes, it is much easier if these tests are auto-
> generated for you so that you don't have to repeat similar code.
> Remove those "duplicates" ...

Manually adding 2^n tests, where n is the number of scopes, is no longer needed because wiith this patch we are autogenerating those test cases.
Comment 5 Joonas Kylmälä 2020-07-15 07:24:22 UTC
Created attachment 106904 [details] [review]
Bug 25113: Refactor CirculationRules.t when testing scope combinations

We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

This patch removes those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.

This also obsoletes the "Get effective issuing rule in correct order"
test in t/db_dependent/Koha/IssuingRules.t

To test:
1. prove t/db_dependent/Koha/CirculationRules.t

Sponsored-by: The National Library of Finland
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 6 Katrin Fischer 2020-08-23 22:02:18 UTC
Created attachment 108963 [details] [review]
Bug 25113: Refactor CirculationRules.t when testing scope combinations

We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

This patch removes those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.

This also obsoletes the "Get effective issuing rule in correct order"
test in t/db_dependent/Koha/IssuingRules.t

To test:
1. prove t/db_dependent/Koha/CirculationRules.t

Sponsored-by: The National Library of Finland
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Jonathan Druart 2020-08-24 10:01:44 UTC
Created attachment 108978 [details] [review]
Bug 25113: Refactor CirculationRules.t when testing scope combinations

We used to test rule scopes by explicitly defining each combination.

When adding new scopes, it is much easier if these tests are auto-
generated for you so that you don't have to repeat similar code.

This patch removes those "duplicates" and adds a method that returns
test cases for each scope as follows:

branchcode categorycode itemtype
__________ ____________ ________
branchcode categorycode itemtype
branchcode categorycode *
branchcode *            itemtype
branchcode *            *
*          categorycode itemtype
*          categorycode *
*          *            itemtype
*          *            *

And automatically extends the test when new scopes are added.

This also obsoletes the "Get effective issuing rule in correct order"
test in t/db_dependent/Koha/IssuingRules.t

To test:
1. prove t/db_dependent/Koha/CirculationRules.t

Sponsored-by: The National Library of Finland
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

JD amended patch: perl tidy
Comment 8 Jonathan Druart 2020-08-24 10:32:59 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 9 Lucas Gass 2020-09-04 19:45:56 UTC
enhancement will not be backported to 20.05.x