Bug 12445 - C4::Suggestions.pm needs more unit tests
Summary: C4::Suggestions.pm needs more unit tests
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Yohann Dufour
QA Contact: Galen Charlton
URL:
Whiteboard:
Keywords: rel_3_16_candidate
Depends on:
Blocks: 12627
  Show dependency treegraph
 
Reported: 2014-06-18 07:55 UTC by Yohann Dufour
Modified: 2016-12-05 21:23 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 12445: Improving unit tests for C4::Suggestions.pm (7.81 KB, patch)
2014-06-19 07:26 UTC, Yohann Dufour
Details | Diff | Splinter Review
Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (13.80 KB, patch)
2014-06-19 14:36 UTC, Yohann Dufour
Details | Diff | Splinter Review
Bug 12445: Improving unit tests for C4::Suggestions.pm (8.04 KB, patch)
2014-06-20 14:04 UTC, Paola Rossi
Details | Diff | Splinter Review
Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (14.11 KB, patch)
2014-06-20 14:04 UTC, Paola Rossi
Details | Diff | Splinter Review
Bug 12445: Improving unit tests for C4::Suggestions.pm (8.12 KB, patch)
2014-07-22 13:37 UTC, Yohann Dufour
Details | Diff | Splinter Review
Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (13.79 KB, patch)
2014-07-22 13:39 UTC, Yohann Dufour
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12445: Improving unit tests for C4::Suggestions.pm (8.19 KB, patch)
2014-07-24 18:57 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (14.11 KB, patch)
2014-07-24 18:58 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 12445 [QA Followup] - Clear issues table before clearing borrrowers table (783 bytes, patch)
2014-07-25 13:13 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 12445: Improving unit tests for C4::Suggestions.pm (8.24 KB, patch)
2014-07-25 13:29 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (14.16 KB, patch)
2014-07-25 13:29 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12445 [QA Followup] - Clear issues table before clearing borrrowers table (827 bytes, patch)
2014-07-25 13:29 UTC, Jonathan Druart
Details | Diff | Splinter Review
[PASSED QA] Bug 12445: Improving unit tests for C4::Suggestions.pm (8.31 KB, patch)
2014-07-27 22:27 UTC, Katrin Fischer
Details | Diff | Splinter Review
[PASSED QA] Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus (14.22 KB, patch)
2014-07-27 22:29 UTC, Katrin Fischer
Details | Diff | Splinter Review
[PASSED QA] Bug 12445 [QA Followup] - Clear issues table before clearing borrrowers table (935 bytes, patch)
2014-07-27 22:29 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Yohann Dufour 2014-06-18 07:55:41 UTC
The routines DelSuggestionsOlderThan, CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion and GetSuggestionByStatus of the module C4::Suggestions.pm are not tested in t/db_dependent/Suggestions.t
Comment 1 Yohann Dufour 2014-06-19 07:26:46 UTC Comment hidden (obsolete)
Comment 2 Yohann Dufour 2014-06-19 14:36:51 UTC Comment hidden (obsolete)
Comment 3 Paola Rossi 2014-06-20 14:02:56 UTC
I've applied against master 3.17.00.008

Everything was OK.

So I've passed the patch to "Signed Off" status.
Comment 4 Paola Rossi 2014-06-20 14:04:01 UTC Comment hidden (obsolete)
Comment 5 Paola Rossi 2014-06-20 14:04:39 UTC Comment hidden (obsolete)
Comment 6 Kyle M Hall 2014-06-20 15:25:27 UTC
Suggestions.t passes on master. When I try with these patches applied I get this:
perl t/db_dependent/Suggestions.t
1..89
ok 1 - use C4::Suggestions;
ok 2 - use C4::Koha;
DBD::mysql::db selectrow_array failed: MySQL server has gone away at /home/koha/kohaclone/C4/Context.pm line 563.
DBD::mysql::db selectrow_array failed: MySQL server has gone away at /home/koha/kohaclone/C4/Context.pm line 563.
# Looks like you planned 89 tests but ran 2.
# Looks like your test exited with 255 just after 2.
Comment 7 Yohann Dufour 2014-06-23 07:22:17 UTC
Kyle, before launching this UT, have you configure your database with a database for test (see bz 10337) ?
Comment 8 Yohann Dufour 2014-06-24 12:58:56 UTC
(In reply to Kyle M Hall from comment #6)
> Suggestions.t passes on master. When I try with these patches applied I get
> this:
> perl t/db_dependent/Suggestions.t
> 1..89
> ok 1 - use C4::Suggestions;
> ok 2 - use C4::Koha;
> DBD::mysql::db selectrow_array failed: MySQL server has gone away at
> /home/koha/kohaclone/C4/Context.pm line 563.
> DBD::mysql::db selectrow_array failed: MySQL server has gone away at
> /home/koha/kohaclone/C4/Context.pm line 563.
> # Looks like you planned 89 tests but ran 2.
> # Looks like your test exited with 255 just after 2.

Since this error is linked to the bug 12472, I change the status to Needs Signed Off
Comment 9 Yohann Dufour 2014-07-22 12:56:04 UTC
Conflict to solve
Comment 10 Yohann Dufour 2014-07-22 13:37:28 UTC Comment hidden (obsolete)
Comment 11 Yohann Dufour 2014-07-22 13:39:24 UTC Comment hidden (obsolete)
Comment 12 Bernardo Gonzalez Kriegel 2014-07-24 18:57:56 UTC Comment hidden (obsolete)
Comment 13 Bernardo Gonzalez Kriegel 2014-07-24 18:58:06 UTC Comment hidden (obsolete)
Comment 14 Katrin Fischer 2014-07-24 19:58:05 UTC
I am sorry, tests fail on my database:

t/db_dependent/Suggestions.t .. 1/91 DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/Suggestions.t line 39.
DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/Suggestions.t line 39.
# Looks like you planned 91 tests but ran 2.
# Looks like your test exited with 255 just after 2.

Can you add some clean up prior to running the tests and switch back to signed off?
Comment 15 Kyle M Hall 2014-07-25 13:13:09 UTC Comment hidden (obsolete)
Comment 16 Jonathan Druart 2014-07-25 13:29:46 UTC Comment hidden (obsolete)
Comment 17 Jonathan Druart 2014-07-25 13:29:50 UTC Comment hidden (obsolete)
Comment 18 Jonathan Druart 2014-07-25 13:29:55 UTC Comment hidden (obsolete)
Comment 19 Jonathan Druart 2014-07-25 13:30:26 UTC
This one is ready to QA.
Comment 20 Katrin Fischer 2014-07-27 22:27:59 UTC
Created attachment 30166 [details] [review]
[PASSED QA] Bug 12445: Improving unit tests for C4::Suggestions.pm

Now, the tests used 'is' instead of 'ok', the tests are wrapped in a transaction, adding tests for the routines NewSuggestion, GetSuggestion, ModSuggestion, GetSuggestionFromBiblionumber and GetInfoFromBiblionumber.

The tests for the routines DelSuggestionsOlderThan, CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion and GetSuggestionByStatus will be arrived in another patch.

Test plan:
1/ Execute the command : prove t/db_dependent/Suggestions.t
2/ The result has to be a success without warning or error :
t/db_dependent/Suggestions.t .. ok
All tests successful.
Files=1, Tests=32,  2 wallclock secs ( 0.03 usr  0.01 sys +  1.49 cusr  0.08 csys =  1.61 CPU)
Result: PASS

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 21 Katrin Fischer 2014-07-27 22:29:09 UTC
Created attachment 30167 [details] [review]
[PASSED QA] Bug 12445: ading unit tests to test the routines : CountSuggestion, ConnectSuggestionAndBiblio, SearchSuggestion, GetSuggestionInfo, DelSuggestion, GetSuggestionByStatus

These routines were not tested

Test plan:
1/ Execute the command : prove t/db_dependent/Suggestions.t
2/ The result has to be a success without error or warning :
t/db_dependent/Suggestions.t .. ok
All tests successful.
Files=1, Tests=89,  1 wallclock secs ( 0.05 usr  0.01 sys +  1.52 cusr  0.08 csys =  1.66 CPU)
Result: PASS

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Test pass, no koha-qa errors

But now there are 91!
prove t/db_dependent/Suggestions.t
t/db_dependent/Suggestions.t .. ok
All tests successful.
Files=1, Tests=91,  2 wallclock secs ( 0.05 usr  0.00 sys +  1.77 cusr  0.10 csys =  1.92 CPU)
Result: PASS

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 22 Katrin Fischer 2014-07-27 22:29:22 UTC
Created attachment 30168 [details] [review]
[PASSED QA] Bug 12445 [QA Followup] - Clear issues table before clearing borrrowers table

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests pass, even more now than before.
Comment 23 Tomás Cohen Arazi 2014-07-29 19:42:42 UTC
Patches pushed to master.

Thanks Yohann!
Comment 24 Mason James 2015-03-26 02:30:00 UTC
Possible selection for 3.16.x
Comment 25 Mason James 2015-05-29 07:37:34 UTC
Pushed to 3.16.x, will be in 3.16.11