View | Details | Raw Unified | Return to bug 17371
Collapse All | Expand All

(-)a/api/v1/swagger/definitions/biblio.json (-2 / +2 lines)
Lines 33-43 Link Here
33
      "description": "publication or copyright date from the MARC record"
33
      "description": "publication or copyright date from the MARC record"
34
    },
34
    },
35
    "timestamp": {
35
    "timestamp": {
36
      "type": "string",
36
      "type": ["string", "null"],
37
      "description": "date and time this record was last touched"
37
      "description": "date and time this record was last touched"
38
    },
38
    },
39
    "datecreated": {
39
    "datecreated": {
40
      "type": "string",
40
      "type": ["string", "null"],
41
      "description": "the date this record was added to Koha"
41
      "description": "the date this record was added to Koha"
42
    },
42
    },
43
    "abstract": {
43
    "abstract": {
(-)a/t/db_dependent/api/v1/biblios.t (-38 / +47 lines)
Lines 17-57 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use t::lib::TestBuilder;
21
22
use Test::More tests => 3;
20
use Test::More tests => 3;
23
use Test::Mojo;
21
use Test::Mojo;
22
use Test::Warn;
23
24
use t::lib::TestBuilder;
25
use t::lib::Mocks;
26
24
use Data::Dumper;
27
use Data::Dumper;
25
use C4::Auth;
28
use C4::Auth;
26
use C4::Context;
29
use C4::Context;
30
27
use Koha::Database;
31
use Koha::Database;
28
use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'UNIMARC' );
32
use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' );
33
34
my $schema  = Koha::Database->new->schema;
35
my $builder = t::lib::TestBuilder->new;
36
37
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' );
38
39
my $remote_address = '127.0.0.1';
40
my $t              = Test::Mojo->new('Koha::REST::V1');
29
41
30
BEGIN {
42
BEGIN {
31
    use_ok('Koha::Biblios');
43
    use_ok('Koha::Biblios');
32
}
44
}
33
45
34
my $schema  = Koha::Database->schema;
35
my $dbh     = C4::Context->dbh;
46
my $dbh     = C4::Context->dbh;
36
my $builder = t::lib::TestBuilder->new;
37
38
$ENV{REMOTE_ADDR} = '127.0.0.1';
39
my $t = Test::Mojo->new('Koha::REST::V1');
40
41
$schema->storage->txn_begin;
42
47
43
my $file = MARC::File::XML->in( 't/db_dependent/Record/testrecords/marcxml_utf8.xml' );
48
my $file = MARC::File::XML->in( 't/db_dependent/Record/testrecords/marcxml_utf8.xml' );
44
my $record = $file->next();
49
my $record = $file->next();
45
my ( $biblionumber, $itemnumber );
50
51
$schema->storage->txn_begin;
46
52
47
my $librarian = $builder->build({
53
my $librarian = $builder->build({
48
    source => "Borrower",
54
        source => "Borrower",
49
    value => {
55
        value => {
50
        categorycode => 'S',
56
            categorycode => 'S',
51
        branchcode => 'NPL',
57
            branchcode => 'NPL',
52
        flags => 1, # editcatalogue
58
            flags => 1, # editcatalogue
53
    },
59
        },
54
});
60
    });
55
61
56
my $session = C4::Auth::get_session('');
62
my $session = C4::Auth::get_session('');
57
$session->param('number', $librarian->{ borrowernumber });
63
$session->param('number', $librarian->{ borrowernumber });
Lines 60-90 $session->param('ip', '127.0.0.1'); Link Here
60
$session->param('lasttime', time());
66
$session->param('lasttime', time());
61
$session->flush;
67
$session->flush;
62
68
69
my ( $biblionumber, $itemnumber );
70
63
subtest 'Create biblio' => sub {
71
subtest 'Create biblio' => sub {
64
	plan tests => 5;
72
    plan tests => 5;
65
73
66
	my $tx = $t->ua->build_tx(POST => '/api/v1/biblios' => $record->as_xml());
74
    my $tx = $t->ua->build_tx(POST => '/api/v1/biblios' => $record->as_xml());
67
	$tx->req->env({REMOTE_ADDR => '127.0.0.1'});
75
    $tx->req->env({REMOTE_ADDR => '127.0.0.1'});
68
	$tx->req->cookies({name => 'CGISESSID', value => $session->id});
76
    $tx->req->cookies({name => 'CGISESSID', value => $session->id});
69
	$t->request_ok($tx)
77
    $t->request_ok($tx)
70
	  ->status_is(201);
78
    ->status_is(201);
71
	$biblionumber = $tx->res->json->{biblionumber};
79
    $biblionumber = $tx->res->json->{biblionumber};
72
	$itemnumber   = $tx->res->json->{items};
80
    $itemnumber   = $tx->res->json->{items};
73
81
74
	$t->json_is('/biblionumber' => $biblionumber)
82
    $t->json_is('/biblionumber' => $biblionumber)
75
	  ->json_is('/items'      => $itemnumber)
83
    ->json_is('/items'      => $itemnumber)
76
	  ->header_like(Location => qr/$biblionumber/, 'Location header contains biblionumber');
84
    ->header_like(Location => qr/$biblionumber/, 'Location header contains biblionumber');
85
77
};
86
};
78
87
79
subtest 'Delete biblio' => sub {
88
subtest 'Delete biblio' => sub {
80
	plan tests => 2;
89
    plan tests => 2;
81
90
82
	my $tx = $t->ua->build_tx(DELETE => "/api/v1/biblios/$biblionumber");
91
    my $tx = $t->ua->build_tx(DELETE => "/api/v1/biblios/$biblionumber");
83
	$tx->req->env({REMOTE_ADDR => '127.0.0.1'});
92
    $tx->req->env({REMOTE_ADDR => '127.0.0.1'});
84
	$tx->req->cookies({name => 'CGISESSID', value => $session->id});
93
    $tx->req->cookies({name => 'CGISESSID', value => $session->id});
85
	$t->request_ok($tx)
94
    $t->request_ok($tx)
86
	  ->status_is(200);
95
    ->status_is(200);
87
};
88
96
97
};
89
98
90
$schema->storage->txn_rollback;
99
$schema->storage->txn_rollback;
(-)a/t/db_dependent/api/v1/swagger/definitions.t (-2 / +6 lines)
Lines 46-52 my $schema = Koha::Database->new->schema; Link Here
46
my @definition_names = keys %{ $api_spec->{definitions} };
46
my @definition_names = keys %{ $api_spec->{definitions} };
47
47
48
subtest 'api/v1/definitions/*.json up-to-date with corresponding Koha-object' => sub {
48
subtest 'api/v1/definitions/*.json up-to-date with corresponding Koha-object' => sub {
49
    plan tests => 2*(scalar(@definition_names) - 1);
49
50
    # we have to subtract definitions which are not Koha-object (only one subtest for those):
51
    # error
52
    # holds
53
    # biblios
54
    plan tests => 2*(scalar(@definition_names)) - 3;
50
55
51
    foreach my $name (@definition_names) {
56
    foreach my $name (@definition_names) {
52
        my $definition = $api_spec->{definitions}->{$name};
57
        my $definition = $api_spec->{definitions}->{$name};
53
- 

Return to bug 17371