Bugzilla – Attachment 189123 Details for
Bug 29668
Add API route to create a basket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29668: Move tests
1d2dd77.patch (text/plain), 4.47 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-11-05 16:51:15 UTC
(
hide
)
Description:
Bug 29668: Move tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-11-05 16:51:15 UTC
Size:
4.47 KB
patch
obsolete
>From 1d2dd776bd30af0117995dbcb430910b2e21c3a9 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 5 Nov 2025 13:47:59 -0300 >Subject: [PATCH] Bug 29668: Move tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/acquisitions_baskets.t | 52 ++++++++++++++- > .../api/v1/acquisitions_baskets/post.t | 63 ------------------- > 2 files changed, 51 insertions(+), 64 deletions(-) > delete mode 100644 t/db_dependent/api/v1/acquisitions_baskets/post.t > >diff --git a/t/db_dependent/api/v1/acquisitions_baskets.t b/t/db_dependent/api/v1/acquisitions_baskets.t >index 604422bf108..dfcca47b691 100755 >--- a/t/db_dependent/api/v1/acquisitions_baskets.t >+++ b/t/db_dependent/api/v1/acquisitions_baskets.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::Mojo; > > use t::lib::TestBuilder; >@@ -97,3 +97,53 @@ subtest 'list() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'add() tests' => sub { >+ >+ plan tests => 14; >+ >+ $schema->storage->txn_begin; >+ >+ my $vendor = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Booksellers', >+ } >+ ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ >+ my $url = "//$userid:$password@/api/v1/acquisitions/baskets"; >+ >+ $t->post_ok( $url, json => {} )->status_is(403); >+ >+ $schema->resultset('UserPermission')->create( >+ { >+ borrowernumber => $patron->borrowernumber, >+ module_bit => 11, >+ code => 'order_manage', >+ } >+ ); >+ >+ $t->post_ok( $url, json => {} )->status_is(400); >+ >+ $t->post_ok( $url, json => { vendor_id => $vendor->id } )->status_is(201)->json_has('/basket_id') >+ ->json_is( '/vendor_id', $vendor->id ); >+ >+ my $basket = { >+ vendor_id => $vendor->id, >+ name => 'Basket #1', >+ vendor_note => 'Vendor note', >+ }; >+ $t->post_ok( $url, json => $basket )->status_is(201)->json_has('/basket_id') >+ ->json_is( '/vendor_id', $basket->{vendor_id} )->json_is( '/name', $basket->{name} ) >+ ->json_is( '/vendor_note', $basket->{vendor_note} ); >+ >+ $schema->storage->txn_rollback; >+}; >diff --git a/t/db_dependent/api/v1/acquisitions_baskets/post.t b/t/db_dependent/api/v1/acquisitions_baskets/post.t >deleted file mode 100644 >index d0daabf14ba..00000000000 >--- a/t/db_dependent/api/v1/acquisitions_baskets/post.t >+++ /dev/null >@@ -1,63 +0,0 @@ >-#!/usr/bin/env perl >- >-use Modern::Perl; >- >-use Test::More tests => 14; >-use Test::Mojo; >- >-use t::lib::Mocks; >-use t::lib::TestBuilder; >- >-use Koha::Database; >- >-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'); >- >-$schema->storage->txn_begin; >- >-my $bookseller = $builder->build_object( >- { >- class => 'Koha::Acquisition::Booksellers', >- } >-); >-my $patron = $builder->build_object( >- { >- class => 'Koha::Patrons', >- value => { flags => 0 } >- } >-); >-my $password = 'thePassword123'; >-$patron->set_password( { password => $password, skip_validation => 1 } ); >-my $userid = $patron->userid; >- >-my $url = "//$userid:$password@/api/v1/acquisitions/baskets"; >- >-$t->post_ok( $url, json => {} )->status_is(403); >- >-$schema->resultset('UserPermission')->create( >- { >- borrowernumber => $patron->borrowernumber, >- module_bit => 11, >- code => 'order_manage', >- } >-); >- >-$t->post_ok( $url, json => {} )->status_is(400); >- >-$t->post_ok( $url, json => { vendor_id => $bookseller->id } )->status_is(201)->json_has('/basket_id') >- ->json_is( '/vendor_id', $bookseller->id ); >- >-my $basket = { >- vendor_id => $bookseller->id, >- name => 'Basket #1', >- vendor_note => 'Vendor note', >-}; >-$t->post_ok( $url, json => $basket )->status_is(201)->json_has('/basket_id') >- ->json_is( '/vendor_id', $basket->{vendor_id} )->json_is( '/name', $basket->{name} ) >- ->json_is( '/vendor_note', $basket->{vendor_note} ); >- >-$schema->storage->txn_rollback; >-- >2.51.2 >
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 29668
:
128371
|
183072
|
183073
|
183074
|
189122
|
189123
|
189124
|
189227
|
189228
|
189229