Bug 14878

Summary: Tests - Create the branchcodes if needed
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: alex.arnaud, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 15081    
Bug Blocks: 10273, 16390    
Attachments: Bug 14878: Tests - Create the branchcodes when needed
Bug 14878: Tests - Create the branchcodes when needed
Bug 14878: Tests - Create the branchcodes when needed
Bug 14878: (QA followup) Remove useless diag
[PASSED QA] Bug 14878: Tests - Create the branchcodes when needed
[PASSED QA] Bug 14878: (QA followup) Remove useless diag

Description Jonathan Druart 2015-09-22 16:38:55 UTC
Tests assume that the branchcodes CPL/MPL/etc. already exist in the DB.
If they need them, they should create them.
Comment 1 Jonathan Druart 2015-09-22 16:43:30 UTC Comment hidden (obsolete)
Comment 2 Alex Arnaud 2015-11-03 16:35:26 UTC
This patch is quite not esay to test because lot of things remain "db dependent".
Jonathan, i did the following (tell me if i'm wrong):

- I get the database content provided in bug 10337 (to satisfy all db dependent things),
- i created a branchcode 'FOO' on my database and change all borrowers branchcodes with this one,
- i deleted all other branches
- launch tests on all changed files and get errors on t/db_dependent/Members.t and 
t/db_dependent/Serials_2.t

t/db_dependent/Members.t: Failed test 'Member Changed' (Mismatching member details)
t/db_dependent/Serials_2.t: A mysql error
Comment 3 Tomás Cohen Arazi 2015-11-03 17:28:18 UTC
This one is in conflict with bug 15081, that aims to let the test files handle the transactions on their own.

I think the transaction should be started/rolled back when the test writer considers it needs to. An example: if we want each subtest to rollback when it finish, DBIx::Class will complain about nested transactions. And if it doesn't rollback explicitly there would be side effects between tests.
Comment 4 Jonathan Druart 2015-11-06 13:05:51 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2015-11-06 13:06:41 UTC
Conflicts with bug 15081 fixed.
Comment 6 Tomás Cohen Arazi 2015-11-06 17:50:38 UTC Comment hidden (obsolete)
Comment 7 Tomás Cohen Arazi 2015-11-06 17:50:44 UTC Comment hidden (obsolete)
Comment 8 Tomás Cohen Arazi 2015-11-06 17:51:19 UTC
Nice job Jonathan!
Comment 9 Kyle M Hall 2015-11-06 18:51:31 UTC
Created attachment 44601 [details] [review]
[PASSED QA] Bug 14878: Tests - Create the branchcodes when needed

Tests assume that the branchcodes CPL/MPL/etc. already exist in the DB.
If they need them, they should create them.

Test plan:
Execute the differente test files on a DB without any branchcode or
at least without CPL/MPL branches.
Confirm that the tests pass.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Kyle M Hall 2015-11-06 18:51:42 UTC
Created attachment 44602 [details] [review]
[PASSED QA] Bug 14878: (QA followup) Remove useless diag

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Tomás Cohen Arazi 2015-11-06 18:54:29 UTC
Patches pushed to master.

Thanks Jonathan!