Bug 25113 - Make CirculationRules.t flexible for new scope combinations
Summary: Make CirculationRules.t flexible for new scope combinations
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Lari Taskula
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 25089
  Show dependency treegraph
 
Reported: 2020-04-11 19:54 UTC by Lari Taskula
Modified: 2021-06-14 21:33 UTC (History)
3 users (show)

See Also:
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


Attachments
Bug 25113: Refactor CirculationRules.t when testing scope combinations (20.97 KB, patch)
2020-04-11 19:58 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 25113: Refactor CirculationRules.t when testing scope combinations (21.14 KB, patch)
2020-04-21 10:42 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 25113: Refactor CirculationRules.t when testing scope combinations (21.29 KB, patch)
2020-07-15 07:24 UTC, Joonas Kylmälä
Details | Diff | Splinter Review
Bug 25113: Refactor CirculationRules.t when testing scope combinations (21.36 KB, patch)
2020-08-23 22:02 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 25113: Refactor CirculationRules.t when testing scope combinations (21.51 KB, patch)
2020-08-24 10:01 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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