From 8e60e0adc17ac6eb8b93a782b71106385bb509e8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 16 Feb 2016 13:28:27 -0500 Subject: [PATCH] LP#1367926: add some unit tests - a pgTAP test of the new 'bre.extern' include option for unapi.bre() - tests for OpenILS::WWW::SuperCat::unapi2_formats and OpenILS::Utils::TagURI Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../src/perlmods/t/18-OpenILS-WWW-SuperCat.t | 27 ++++++++++++++++++- Open-ILS/src/sql/Pg/t/unapi.pg | 12 +++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/t/unapi.pg diff --git a/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t b/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t index ffffba62ff..39fae1cda0 100644 --- a/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t +++ b/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t @@ -1,8 +1,33 @@ #!perl -T -use Test::More tests => 2; +use Test::More tests => 10; +use Test::Output; BEGIN { use_ok( 'OpenILS::WWW::SuperCat' ); } use_ok( 'OpenILS::WWW::SuperCat::Feed' ); +use_ok( 'OpenILS::Utils::TagURI' ); + +my $tag = 'tag::U2@bre/454{holdings_xml}'; +my $u = OpenILS::Utils::TagURI->new($tag); +is( $u->id, 454, 'parsed correct ID' ); +is( $u->classname, 'bre', 'parsed correct class name' ); +is( $u->toURI, $tag, 'can reconstruct unAPI ID' ); + +my $apache_stub; +stdout_like { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u) } + qr/marcxml/, + 'U2 formats list for bre includes marcxml'; + +stdout_unlike { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u) } + qr/name="xml"/, + 'U2 formats list for bre does not include xml'; + +my $u2 = OpenILS::Utils::TagURI->new('tag::U2@acn/4'); +stdout_like { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u2) } + qr/name="xml"/, + 'U2 formats list for acn does includes xml'; +stdout_unlike { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u2) } + qr/name="marcxml"/, + 'U2 formats list for acn does not includes marcxml'; diff --git a/Open-ILS/src/sql/Pg/t/unapi.pg b/Open-ILS/src/sql/Pg/t/unapi.pg new file mode 100644 index 0000000000..15b1919078 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/unapi.pg @@ -0,0 +1,12 @@ +BEGIN; + +SELECT plan(1); + +SELECT matches( + (SELECT unapi.bre(-1, 'marcxml', 'bre', '{bre.extern}', '-')::TEXT), + ' element' +); + +SELECT * FROM finish(); +ROLLBACK; -- 2.43.2