Bug 33870

Summary: Remove T::D::C from Sitemapper.t
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Test SuiteAssignee: Marcel de Rooy <m.de.rooy>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, pedro.amorim
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:
23.11.00
Circulation function:
Bug Depends on:    
Bug Blocks: 33871, 34336    
Attachments: Bug 33870: Make $MAX in Sitemapper::Writer global
Bug 33870: Polishing Sitemapper.t
Bug 33870: Fix indentation in subtest
Bug 33870: Make $MAX in Sitemapper::Writer global
Bug 33870: Polishing Sitemapper.t
Bug 33870: Fix indentation in subtest
Bug 33870: Make $MAX in Sitemapper::Writer global
Bug 33870: Polishing Sitemapper.t
Bug 33870: Fix indentation in subtest

Description Marcel de Rooy 2023-05-31 13:14:27 UTC
Not that hard. And a follow-up adds a filtering parameter.
Comment 1 Marcel de Rooy 2023-05-31 13:18:15 UTC
Created attachment 151875 [details] [review]
Bug 33870: Make $MAX in Sitemapper::Writer global

This should preferably not be a lexical variable (in case we ever
should call this under Plack). A global variable will also simplify
testing (see next patch).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2023-05-31 13:18:17 UTC
Created attachment 151876 [details] [review]
Bug 33870: Polishing Sitemapper.t

Create subtest.
Remove (useless) mock on DateTime.
Remove T::D::C module, add TestBuilder.
Replace local slurp function by use File::Slurp.

Test plan:
Run t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2023-05-31 13:18:19 UTC
Created attachment 151877 [details] [review]
Bug 33870: Fix indentation in subtest

Test plan:
git diff -w HEAD~1.. t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 Pedro Amorim 2023-07-14 09:47:14 UTC
Hi Marcel, I'm looking at this to attempt an SO but I'm not 100% familiar with tests or Sitemapper.t.

My understanding of this patch is that we're cleaning up Sitemapper.t and bringing it up to par a bit more with the most recent way of writing tests, e.g. Slurp.

$schema->storage->txn_rollback; at the end also seems like something that was missing and I believe it should've always been there?

I don't understand or see the need for the "FIXME" comment, if for the tests we need to make sure the only biblios that exist are the 2 biblios we're creating in the tests, isn't "Koha::Biblios->delete;" a perfectly fine way of doing it?
Comment 5 Marcel de Rooy 2023-07-14 10:00:31 UTC
(In reply to Pedro Amorim from comment #4)
> Hi Marcel, I'm looking at this to attempt an SO but I'm not 100% familiar
> with tests or Sitemapper.t.
> 
> My understanding of this patch is that we're cleaning up Sitemapper.t and
> bringing it up to par a bit more with the most recent way of writing tests,
> e.g. Slurp.
> 
> $schema->storage->txn_rollback; at the end also seems like something that
> was missing and I believe it should've always been there?
Yes

> I don't understand or see the need for the "FIXME" comment, if for the tests
> we need to make sure the only biblios that exist are the 2 biblios we're
> creating in the tests, isn't "Koha::Biblios->delete;" a perfectly fine way
> of doing it?
Yes, it works. And we do it more often in tests. But it is not the most elegant way. So maybe TODO could have been more appropriate?
Comment 6 Pedro Amorim 2023-07-14 10:04:44 UTC
Created attachment 153453 [details] [review]
Bug 33870: Make $MAX in Sitemapper::Writer global

This should preferably not be a lexical variable (in case we ever
should call this under Plack). A global variable will also simplify
testing (see next patch).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 7 Pedro Amorim 2023-07-14 10:04:47 UTC
Created attachment 153454 [details] [review]
Bug 33870: Polishing Sitemapper.t

Create subtest.
Remove (useless) mock on DateTime.
Remove T::D::C module, add TestBuilder.
Replace local slurp function by use File::Slurp.

Test plan:
Run t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 8 Pedro Amorim 2023-07-14 10:04:49 UTC
Created attachment 153455 [details] [review]
Bug 33870: Fix indentation in subtest

Test plan:
git diff -w HEAD~1.. t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 9 Jonathan Druart 2023-07-27 14:08:30 UTC
    # FIXME Would be nice to remove both deletes again
    Koha::Checkouts->delete;
    Koha::Biblios->delete;


We should not do that, even with a FIXME.
Comment 10 Pedro Amorim 2023-07-27 15:04:49 UTC
(In reply to Jonathan Druart from comment #9)
>     # FIXME Would be nice to remove both deletes again
>     Koha::Checkouts->delete;
>     Koha::Biblios->delete;
> 
> 
> We should not do that, even with a FIXME.

They get removed in bug 33871
Comment 11 Jonathan Druart 2023-09-01 10:14:06 UTC
Created attachment 155094 [details] [review]
Bug 33870: Make $MAX in Sitemapper::Writer global

This should preferably not be a lexical variable (in case we ever
should call this under Plack). A global variable will also simplify
testing (see next patch).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Jonathan Druart 2023-09-01 10:14:09 UTC
Created attachment 155095 [details] [review]
Bug 33870: Polishing Sitemapper.t

Create subtest.
Remove (useless) mock on DateTime.
Remove T::D::C module, add TestBuilder.
Replace local slurp function by use File::Slurp.

Test plan:
Run t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 13 Jonathan Druart 2023-09-01 10:14:12 UTC
Created attachment 155096 [details] [review]
Bug 33870: Fix indentation in subtest

Test plan:
git diff -w HEAD~1.. t/db_dependent/Sitemapper.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

JD amended patch: tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 14 Tomás Cohen Arazi (tcohen) 2023-09-01 14:24:21 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 15 Fridolin Somers 2023-09-08 05:52:52 UTC
Not backported to 23.05.x