Bug 30719: (QA follow-up) Rename illbatches endpoint to ill/batches

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Pedro Amorim 2023-10-09 12:23:57 +00:00 committed by Tomas Cohen Arazi
parent 17499fbf06
commit edb048de78
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
7 changed files with 52 additions and 52 deletions

View file

@ -106,7 +106,7 @@ Get one batch
sub get {
my $c = shift->openapi->valid_input;
my $batchid = $c->param('illbatch_id');
my $batchid = $c->param('ill_batch_id');
my $batch = Koha::Illbatches->find($batchid);
@ -204,7 +204,7 @@ Update a batch
sub update {
my $c = shift->openapi->valid_input or return;
my $batch = Koha::Illbatches->find( $c->param('illbatch_id') );
my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') );
if ( not defined $batch ) {
return $c->render(
@ -253,7 +253,7 @@ sub delete {
my $c = shift->openapi->valid_input or return;
my $batch = Koha::Illbatches->find( $c->param('illbatch_id') );
my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') );
if ( not defined $batch ) {
return $c->render( status => 404, openapi => { error => "ILL batch not found" } );

View file

@ -1,5 +1,5 @@
---
type: array
items:
$ref: "illbatch.yaml"
$ref: "ill_batch.yaml"
additionalProperties: false

View file

@ -1,10 +1,10 @@
---
/illbatches:
/ill/batches:
get:
x-mojo-to: Illbatches#list
operationId: listIllbatches
tags:
- illbatches
- ill_batches
summary: List ILL batches
parameters: []
produces:
@ -13,7 +13,7 @@
"200":
description: A list of ILL batches
schema:
$ref: "../swagger.yaml#/definitions/illbatches"
$ref: "../swagger.yaml#/definitions/ill_batches"
"401":
description: Authentication required
schema:
@ -44,7 +44,7 @@
x-mojo-to: Illbatches#add
operationId: addIllbatch
tags:
- illbatches
- ill_batches
summary: Add ILL batch
parameters:
- name: body
@ -52,14 +52,14 @@
description: A JSON object containing informations about the new batch
required: true
schema:
$ref: "../swagger.yaml#/definitions/illbatch"
$ref: "../swagger.yaml#/definitions/ill_batch"
produces:
- application/json
responses:
"201":
description: Batch added
schema:
$ref: "../swagger.yaml#/definitions/illbatch"
$ref: "../swagger.yaml#/definitions/ill_batch"
"400":
description: Bad request
schema:
@ -94,15 +94,15 @@
x-koha-authorization:
permissions:
ill: "1"
"/illbatches/{illbatch_id}":
"/ill/batches/{ill_batch_id}":
get:
x-mojo-to: Illbatches#get
operationId: getIllbatches
tags:
- illbatches
- ill_batches
summary: Get ILL batch
parameters:
- name: illbatch_id
- name: ill_batch_id
in: path
description: ILL batch id/name/contents
required: true
@ -113,7 +113,7 @@
"200":
description: An ILL batch
schema:
$ref: "../swagger.yaml#/definitions/illbatch"
$ref: "../swagger.yaml#/definitions/ill_batch"
"401":
description: Authentication required
schema:
@ -144,16 +144,16 @@
x-mojo-to: Illbatches#update
operationId: updateIllBatch
tags:
- illbatches
- ill_batches
summary: Update batch
parameters:
- $ref: "../swagger.yaml#/parameters/illbatch_id_pp"
- $ref: "../swagger.yaml#/parameters/ill_batch_id_pp"
- name: body
in: body
description: A JSON object containing information on the batch
required: true
schema:
$ref: "../swagger.yaml#/definitions/illbatch"
$ref: "../swagger.yaml#/definitions/ill_batch"
consumes:
- application/json
produces:
@ -162,7 +162,7 @@
"200":
description: An ILL batch
schema:
$ref: "../swagger.yaml#/definitions/illbatch"
$ref: "../swagger.yaml#/definitions/ill_batch"
"400":
description: Bad request
schema:
@ -197,10 +197,10 @@
x-mojo-to: Illbatches#delete
operationId: deleteBatch
tags:
- illbatches
- ill_batches
summary: Delete ILL batch
parameters:
- $ref: "../swagger.yaml#/parameters/illbatch_id_pp"
- $ref: "../swagger.yaml#/parameters/ill_batch_id_pp"
produces:
- application/json
responses:

View file

@ -64,10 +64,10 @@ definitions:
$ref: ./definitions/ill_status.yaml
ill_request:
$ref: ./definitions/ill_request.yaml
illbatch:
$ref: ./definitions/illbatch.yaml
illbatches:
$ref: ./definitions/illbatches.yaml
ill_batch:
$ref: ./definitions/ill_batch.yaml
ill_batches:
$ref: ./definitions/ill_batches.yaml
illbatchstatus:
$ref: ./definitions/illbatchstatus.yaml
illbatchstatuses:
@ -277,10 +277,10 @@ paths:
$ref: "./paths/ill_backends.yaml#/~1ill~1backends~1{ill_backend_id}"
/ill/requests:
$ref: ./paths/ill_requests.yaml#/~1ill~1requests
/illbatches:
$ref: ./paths/illbatches.yaml#/~1illbatches
"/illbatches/{illbatch_id}":
$ref: "./paths/illbatches.yaml#/~1illbatches~1{illbatch_id}"
/ill/batches:
$ref: ./paths/ill_batches.yaml#/~1ill~1batches
"/ill/batches/{ill_batch_id}":
$ref: "./paths/ill_batches.yaml#/~1ill~1batches~1{ill_batch_id}"
/illbatchstatuses:
$ref: ./paths/illbatchstatuses.yaml#/~1illbatchstatuses
"/illbatchstatuses/{illbatchstatus_code}":
@ -537,10 +537,10 @@ parameters:
name: hold_id
required: true
type: integer
illbatch_id_pp:
ill_batch_id_pp:
description: Internal ILL batch identifier
in: path
name: illbatch_id
name: ill_batch_id
required: true
type: integer
illbatchstatus_code_pp:
@ -880,7 +880,7 @@ tags:
name: ill_backends
x-displayName: ILL backends
- description: "Manage ILL module batches\n"
name: illbatches
name: ill_batches
x-displayName: ILL batches
- description: "Manage ILL module batch statuses\n"
name: illbatchstatuses

View file

@ -13,7 +13,7 @@
// Make a batch API call, returning the resulting promise
window.doBatchApiRequest = function (url, options) {
var batchListApi = '/api/v1/illbatches';
var batchListApi = '/api/v1/ill/batches';
var fullUrl = batchListApi + (url ? url : '');
return doApiRequest(fullUrl, options);
};

View file

@ -60,7 +60,7 @@ subtest 'list() tests' => sub {
## Authorized user tests
# No batches, so empty array should be returned
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_is( [] );
$t->get_ok("//$userid:$password@/api/v1/ill/batches")->status_is(200)->json_is( [] );
my $batch = $builder->build_object(
{
@ -85,7 +85,7 @@ subtest 'list() tests' => sub {
);
# One batch created, should get returned
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_has( '/0/batch_id', 'Batch ID' )
$t->get_ok("//$userid:$password@/api/v1/ill/batches")->status_is(200)->json_has( '/0/batch_id', 'Batch ID' )
->json_has( '/0/name', 'Batch name' )->json_has( '/0/backend', 'Backend name' )
->json_has( '/0/patron_id', 'Borrowernumber' )->json_has( '/0/library_id', 'Branchcode' )
->json_has( '/0/patron', 'patron embedded' )->json_has( '/0/branch', 'branch embedded' )
@ -98,7 +98,7 @@ subtest 'list() tests' => sub {
my $batch_with_another_name = $builder->build_object( { class => 'Koha::Illbatches' } );
# Two batches created, they should both be returned
$t->get_ok("//$userid:$password@/api/v1/illbatches")->status_is(200)->json_has( '/0', 'has first batch' )
$t->get_ok("//$userid:$password@/api/v1/ill/batches")->status_is(200)->json_has( '/0', 'has first batch' )
->json_has( '/1', 'has second batch' );
my $patron = $builder->build_object(
@ -115,7 +115,7 @@ subtest 'list() tests' => sub {
my $unauth_userid = $patron->userid;
# Unauthorized access
$t->get_ok("//$unauth_userid:$password@/api/v1/illbatches")->status_is(403);
$t->get_ok("//$unauth_userid:$password@/api/v1/ill/batches")->status_is(403);
$schema->storage->txn_rollback;
};
@ -160,19 +160,19 @@ subtest 'get() tests' => sub {
$patron->set_password( { password => $password, skip_validation => 1 } );
my $unauth_userid = $patron->userid;
$t->get_ok( "//$userid:$password@/api/v1/illbatches/" . $batch->id )->status_is(200)
$t->get_ok( "//$userid:$password@/api/v1/ill/batches/" . $batch->id )->status_is(200)
->json_has( '/batch_id', 'Batch ID' )->json_has( '/name', 'Batch name' )
->json_has( '/backend', 'Backend name' )->json_has( '/patron_id', 'Borrowernumber' )
->json_has( '/library_id', 'Branchcode' )->json_has( '/patron', 'patron embedded' )
->json_has( '/branch', 'branch embedded' )->json_has( '/requests_count', 'request count' );
$t->get_ok( "//$unauth_userid:$password@/api/v1/illbatches/" . $batch->id )->status_is(403);
$t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batches/" . $batch->id )->status_is(403);
my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } );
my $non_existent_id = $batch_to_delete->id;
$batch_to_delete->delete;
$t->get_ok("//$userid:$password@/api/v1/illbatches/$non_existent_id")->status_is(404)
$t->get_ok("//$userid:$password@/api/v1/ill/batches/$non_existent_id")->status_is(404)
->json_is( '/error' => 'ILL batch not found' );
$schema->storage->txn_rollback;
@ -217,7 +217,7 @@ subtest 'add() tests' => sub {
};
# Unauthorized attempt to write
$t->post_ok( "//$unauth_userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(403);
$t->post_ok( "//$unauth_userid:$password@/api/v1/ill/batches" => json => $batch_metadata )->status_is(403);
# Authorized attempt to write invalid data
my $batch_with_invalid_field = {
@ -225,7 +225,7 @@ subtest 'add() tests' => sub {
doh => 1
};
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_with_invalid_field )->status_is(400)
$t->post_ok( "//$userid:$password@/api/v1/ill/batches" => json => $batch_with_invalid_field )->status_is(400)
->json_is(
"/errors" => [
{
@ -237,7 +237,7 @@ subtest 'add() tests' => sub {
# Authorized attempt to write
my $batch_id =
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(201)
$t->post_ok( "//$userid:$password@/api/v1/ill/batches" => json => $batch_metadata )->status_is(201)
->json_is( '/name' => $batch_metadata->{name} )->json_is( '/backend' => $batch_metadata->{backend} )
->json_is( '/patron_id' => $librarian->borrowernumber )
->json_is( '/library_id' => $batch_metadata->{library_id} )->json_is( '/statuscode' => $batch_status->code )
@ -245,7 +245,7 @@ subtest 'add() tests' => sub {
# Authorized attempt to create with null id
$batch_metadata->{id} = undef;
$t->post_ok( "//$userid:$password@/api/v1/illbatches" => json => $batch_metadata )->status_is(400)
$t->post_ok( "//$userid:$password@/api/v1/ill/batches" => json => $batch_metadata )->status_is(400)
->json_has('/errors');
$schema->storage->txn_rollback;
@ -282,7 +282,7 @@ subtest 'update() tests' => sub {
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id;
# Unauthorized attempt to update
$t->put_ok( "//$unauth_userid:$password@/api/v1/illbatches/$batch_id" => json =>
$t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batches/$batch_id" => json =>
{ name => 'These are not the droids you are looking for' } )->status_is(403);
my $batch_status = $builder->build_object( { class => 'Koha::IllbatchStatuses' } );
@ -295,7 +295,7 @@ subtest 'update() tests' => sub {
statuscode => $batch_status->code
};
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_missing_field )
$t->put_ok( "//$userid:$password@/api/v1/ill/batches/$batch_id" => json => $batch_with_missing_field )
->status_is(400)->json_is( "/errors" => [ { message => "Missing property.", path => "/body/name" } ] );
# Full object update on PUT
@ -307,7 +307,7 @@ subtest 'update() tests' => sub {
statuscode => $batch_status->code
};
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field )
$t->put_ok( "//$userid:$password@/api/v1/ill/batches/$batch_id" => json => $batch_with_updated_field )
->status_is(200)->json_is( '/name' => 'Master Ploo Koon' );
# Authorized attempt to write invalid data
@ -317,7 +317,7 @@ subtest 'update() tests' => sub {
backend => "Mock"
};
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_invalid_field )
$t->put_ok( "//$userid:$password@/api/v1/ill/batches/$batch_id" => json => $batch_with_invalid_field )
->status_is(400)->json_is(
"/errors" => [
{
@ -331,13 +331,13 @@ subtest 'update() tests' => sub {
my $non_existent_id = $batch_to_delete->id;
$batch_to_delete->delete;
$t->put_ok( "//$userid:$password@/api/v1/illbatches/$non_existent_id" => json => $batch_with_updated_field )
$t->put_ok( "//$userid:$password@/api/v1/ill/batches/$non_existent_id" => json => $batch_with_updated_field )
->status_is(404);
# Wrong method (POST)
$batch_with_updated_field->{id} = 2;
$t->post_ok( "//$userid:$password@/api/v1/illbatches/$batch_id" => json => $batch_with_updated_field )
$t->post_ok( "//$userid:$password@/api/v1/ill/batches/$batch_id" => json => $batch_with_updated_field )
->status_is(404);
$schema->storage->txn_rollback;
@ -372,11 +372,11 @@ subtest 'delete() tests' => sub {
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id;
# Unauthorized attempt to delete
$t->delete_ok("//$unauth_userid:$password@/api/v1/illbatches/$batch_id")->status_is(403);
$t->delete_ok("//$unauth_userid:$password@/api/v1/ill/batches/$batch_id")->status_is(403);
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id")->status_is(204);
$t->delete_ok("//$userid:$password@/api/v1/ill/batches/$batch_id")->status_is(204);
$t->delete_ok("//$userid:$password@/api/v1/illbatches/$batch_id")->status_is(404);
$t->delete_ok("//$userid:$password@/api/v1/ill/batches/$batch_id")->status_is(404);
$schema->storage->txn_rollback;
};