Bug 10333 - UT: Labels/t_Batch.t needs to create its own data
Summary: UT: Labels/t_Batch.t needs to create its own data
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 10273
  Show dependency treegraph
 
Reported: 2013-05-24 12:51 UTC by Jonathan Druart
Modified: 2014-12-07 20:02 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 10333: Labels/t_Batch.t needs to create its own data (4.08 KB, patch)
2013-05-24 12:53 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10333: Labels/t_Batch.t needs to create its own data (4.13 KB, patch)
2013-05-24 23:21 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10333: Labels/t_Batch.t needs to create its own data (4.70 KB, patch)
2013-06-24 07:33 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10333: remove_item should be called just one time (1.28 KB, patch)
2013-08-12 15:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10333: Labels/t_Batch.t needs to create its own data (4.73 KB, patch)
2013-08-19 02:48 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
[PASSED QA] Bug 10333: Labels/t_Batch.t needs to create its own data (4.80 KB, patch)
2013-08-25 17:26 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 Jonathan Druart 2013-05-24 12:51:48 UTC
t/db_dependent/Labels/t_Batch.t depends on the Jenkins database.
We should create the data we want and delete them at the end.
Comment 1 Jonathan Druart 2013-05-24 12:53:56 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2013-05-24 23:21:28 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2013-06-21 13:17:11 UTC
With this patch, the tests now assume that the home and holding branch are in 952 a and b. While this is the Koha default, it's not necessarily true.

I think it would be better to get the values for these fields using GetMarcFromKohaField().
Comment 4 Jonathan Druart 2013-06-24 07:33:43 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2013-07-02 17:04:12 UTC
Looks like this patch needs re-signed off.
Comment 6 Srdjan Jankovic 2013-08-02 03:30:26 UTC
# Testing Batch->get_attr() method.
# Testing Batch->add_item() method.
# Testing Batch->retrieve() method.

#   Failed test at t/db_dependent/Labels/t_Batch.t line 100.
#     Structures begin differing at:
#          $got = '-2'
#     $expected = C4::Labels::Batch=HASH(0x3aaa5b8)
# Retrieved batch object FAILED to verify.
# Testing Batch->remove_item() method.

#   Failed test at t/db_dependent/Labels/t_Batch.t line 109.
#     Structures begin differing at:
#          $got = '-2'
#     $expected = C4::Labels::Batch=HASH(0x3aaa5b8)
# Updated batch object FAILED to verify.
# Testing Batch->delete() method.
# Looks like you planned 33 tests but ran 13.

Do I need some setup first?
Comment 7 Jonathan Druart 2013-08-12 14:56:06 UTC
(In reply to Srdjan Jankovic from comment #6)
> Do I need some setup first?

No, this should be done by this unit tests file.
Comment 8 Jonathan Druart 2013-08-12 15:08:56 UTC Comment hidden (obsolete)
Comment 9 Srdjan Jankovic 2013-08-14 01:40:02 UTC
# Testing Batch->new() method.
# Testing Batch->get_attr() method.
# Testing Batch->add_item() method.
Use of uninitialized value $encoding in string eq at C4/Biblio.pm line 3281.
Use of uninitialized value $encoding in pattern match (m//) at C4/Biblio.pm line 3301.
# Testing Batch->retrieve() method.

#   Failed test at t/db_dependent/Labels/t_Batch.t line 100.
#     Structures begin differing at:
#          $got = '-2'
#     $expected = C4::Labels::Batch=HASH(0x2df33c0)
# Retrieved batch object FAILED to verify.
# Testing Batch->remove_item() method.

#   Failed test at t/db_dependent/Labels/t_Batch.t line 108.
#     Structures begin differing at:
#          $got = '-2'
#     $expected = C4::Labels::Batch=HASH(0x2df33c0)
# Updated batch object FAILED to verify.
# Testing Batch->delete() method.
# Looks like you planned 24 tests but ran 14.
# Looks like you failed 2 tests of 14 run.
Comment 10 Jonathan Druart 2013-08-14 07:40:33 UTC
(In reply to Srdjan Jankovic from comment #9)
> Use of uninitialized value $encoding in string eq at C4/Biblio.pm line 3281.
> Use of uninitialized value $encoding in pattern match (m//) at C4/Biblio.pm
> line 3301.

I have no idea where is the problem. But there 2 lines intrigues me. $encoding is C4::Context->preference("marcflavour"). Don't you have the marcflavour syspref in your DB?
Comment 11 Srdjan Jankovic 2013-08-14 23:45:01 UTC
Yes, I was doing something else and removed the syspref erroneously. When I put it back there are no warnings.
But the test failures stayed. Do you need any more details eg table dumps?
Comment 12 Jonathan Druart 2013-08-16 08:24:11 UTC
(In reply to Srdjan Jankovic from comment #11)
> Yes, I was doing something else and removed the syspref erroneously. When I
> put it back there are no warnings.
> But the test failures stayed. Do you need any more details eg table dumps?

I read the code but I have no idea why they don't pass.
First step, the batch is created and the batch_id is backed-up into the $batch_id var. Items are added to the batch and the retrieve method returns -2 if the batch does not contain items.

Maybe could you warn the $batch_id var (l. 56)? Should be > 1.
To check if items have been added could be interesting too (SELECT * FROM creator_batches WHERE batch_id = $batch_id).
Comment 13 Srdjan Jankovic 2013-08-19 02:48:57 UTC Comment hidden (obsolete)
Comment 14 Srdjan Jankovic 2013-08-19 02:54:05 UTC
C4::Items::AddItemBatchFromMarc was failing (no records returned), I had no CPL branches. You may wish to add some check there, but om if you don't (it's that testing data bug request that is still being discussed).
Comment 15 Katrin Fischer 2013-08-25 17:26:59 UTC
Created attachment 20593 [details] [review]
[PASSED QA] Bug 10333: Labels/t_Batch.t needs to create its own data

prove t/db_dependent/Labels/t_Batch.t
db_dependent/Labels/t_Batch.t .. 1/33 # Testing Batch->new() method.
db_dependent/Labels/t_Batch.t .. ok
All tests successful.
Files=1, Tests=33,  1 wallclock secs ( 0.03 usr  0.00 sys +  0.34 cusr
0.00 csys =  0.37 CPU)
Result: PASS

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 16 Galen Charlton 2013-09-08 02:07:37 UTC
Pushed to master.  Thanks, Jonathan!
Comment 17 Tomás Cohen Arazi 2013-10-08 17:58:55 UTC
This patch has been pushed to 3.12.x, will be in 3.12.6.

Thanks Jonathan!