Bugzilla – Attachment 105539 Details for
Bug 23019
Ability to create 'matching profiles' when importing records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23019: Add tests
Bug-23019-Add-tests.patch (text/plain), 6.17 KB, created by
Agustín Moyano
on 2020-06-03 20:45:19 UTC
(
hide
)
Description:
Bug 23019: Add tests
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-06-03 20:45:19 UTC
Size:
6.17 KB
patch
obsolete
>From 51d23a462709558d6e2d6157642085aadd9bb523 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 15 May 2020 11:09:56 -0300 >Subject: [PATCH] Bug 23019: Add tests > >--- > t/db_dependent/ImportBatch.t | 4 + > t/db_dependent/api/v1/import_batch_profiles.t | 178 ++++++++++++++++++ > 2 files changed, 182 insertions(+) > create mode 100644 t/db_dependent/api/v1/import_batch_profiles.t > >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index f437edc39b..5208a40e37 100644 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -68,6 +68,8 @@ delete $importbatch2->{upload_timestamp}; > delete $importbatch2->{import_batch_id}; > delete $importbatch2->{num_records}; > delete $importbatch2->{num_items}; >+delete $importbatch2->{profile_id}; >+delete $importbatch2->{profile}; > > is_deeply( $importbatch2, $sample_import_batch2, > "GetImportBatch returns the right informations about $sample_import_batch2" ); >@@ -77,6 +79,8 @@ delete $importbatch1->{upload_timestamp}; > delete $importbatch1->{import_batch_id}; > delete $importbatch1->{num_records}; > delete $importbatch1->{num_items}; >+delete $importbatch1->{profile_id}; >+delete $importbatch1->{profile}; > > is_deeply( $importbatch1, $sample_import_batch1, > "GetImportBatch returns the right informations about $sample_import_batch1" ); >diff --git a/t/db_dependent/api/v1/import_batch_profiles.t b/t/db_dependent/api/v1/import_batch_profiles.t >new file mode 100644 >index 0000000000..28417ae3a3 >--- /dev/null >+++ b/t/db_dependent/api/v1/import_batch_profiles.t >@@ -0,0 +1,178 @@ >+#!/usr/bin/env perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 4; >+use Test::Mojo; >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Database; >+use Koha::ImportBatchProfiles; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new(); >+ >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+my $t = Test::Mojo->new('Koha::REST::V1'); >+ >+subtest 'list profiles' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::ImportBatchProfiles->search()->delete; >+ >+ my $ibp1 = $builder->build_object({ class => 'Koha::ImportBatchProfiles', value => { name => 'a_ibp' } }); >+ my $ibp2 = $builder->build_object({ class => 'Koha::ImportBatchProfiles', value => { name => 'b_ibp' } }); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ flags => 1 >+ } >+ } >+ ); >+ >+ my $pwd = 'thePassword123'; >+ $patron->set_password( { password => $pwd, skip_validation => 1 } ); >+ >+ my $uid = $patron->userid; >+ >+ $t->get_ok("//$uid:$pwd@/api/v1/import-batch-profiles?_order_by=+name") >+ ->status_is(200) >+ ->json_is('/0/name', $ibp1->name) >+ ->json_is('/1/name', $ibp2->name); >+ >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ >+subtest 'add profile' => sub { >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::ImportBatchProfiles->search()->delete; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ flags => 1 >+ } >+ } >+ ); >+ >+ my $pwd = 'thePassword123'; >+ $patron->set_password( { password => $pwd, skip_validation => 1 } ); >+ >+ my $uid = $patron->userid; >+ my $post_data = { >+ name => 'profileName', >+ overlay_action => 'overlay_action' >+ }; >+ $t->post_ok("//$uid:$pwd@/api/v1/import-batch-profiles", json => $post_data) >+ ->status_is(201) >+ ->json_has('/profile_id') >+ ->json_is('/name', $post_data->{name}) >+ ->json_is('/overlay_action', $post_data->{overlay_action}); >+ >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ >+subtest 'edit profile' => sub { >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::ImportBatchProfiles->search()->delete; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ flags => 1 >+ } >+ } >+ ); >+ >+ my $pwd = 'thePassword123'; >+ $patron->set_password( { password => $pwd, skip_validation => 1 } ); >+ >+ my $uid = $patron->userid; >+ >+ my $ibp = $builder->build_object({class => 'Koha::ImportBatchProfiles', value => { name => 'someProfile' }}); >+ >+ my $post_data = { >+ name => 'theProfile' >+ }; >+ >+ $t->put_ok("//$uid:$pwd@/api/v1/import-batch-profiles/".$ibp->id, json => $post_data) >+ ->status_is(200) >+ ->json_is('/profile_id', $ibp->id) >+ ->json_is('/name', $post_data->{name}); >+ >+ $ibp->discard_changes; >+ >+ is($ibp->name, $post_data->{name}, 'profile name should be the updated one'); >+ >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ >+subtest 'delete profile' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::ImportBatchProfiles->search()->delete; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ flags => 1 >+ } >+ } >+ ); >+ >+ my $pwd = 'thePassword123'; >+ $patron->set_password( { password => $pwd, skip_validation => 1 } ); >+ >+ my $uid = $patron->userid; >+ >+ my $ibp = $builder->build_object({class => 'Koha::ImportBatchProfiles'}); >+ >+ $t->delete_ok("//$uid:$pwd@/api/v1/import-batch-profiles/".$ibp->id) >+ ->status_is(204); >+ >+ my $search = Koha::ImportBatchProfiles->find($ibp->id); >+ >+ is($search, undef, 'profile should be erased'); >+ >+ >+ $schema->storage->txn_rollback; >+ >+}; >\ No newline at end of file >-- >2.25.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23019
:
104972
|
104973
|
104974
|
104975
|
104976
|
105536
|
105537
|
105538
|
105539
|
105540
|
105541
|
105555
|
105600
|
105601
|
105602
|
105603
|
105604
|
106555
|
109265
|
109266
|
109637
|
112531
|
112532
|
112533
|
112534
|
112535
|
112536
|
112537
|
112715
|
112716
|
112717
|
112718
|
112719
|
112720
|
112721
|
112722
|
113276
|
113277
|
113311
|
113416
|
113421