4 use Test::More tests => 5; # last test to print
6 use Module::Load::Conditional qw( can_load );
9 skip "cannot find WebService::ILS::OverDrive::Patron", 5
10 unless can_load( modules => { 'WebService::ILS::OverDrive::Patron' => undef } );
12 use_ok('Koha::ExternalContent::OverDrive');
14 t::lib::Mocks::mock_preference('OverDriveClientKey', 'DUMMY');
15 t::lib::Mocks::mock_preference('OverDriveClientSecret', 'DUMMY');
16 t::lib::Mocks::mock_preference('OverDriveLibraryID', 'DUMMY');
18 my $client = Koha::ExternalContent::OverDrive->new({koha_session_id => 'DUMMY'});
20 my $user_agent_string = $client->user_agent->agent();
21 ok ($user_agent_string =~ m/^Koha/, 'User Agent string is set')
22 or diag("User Agent string: $user_agent_string");
24 my $base_url = "http://mykoha.org";
25 ok ($client->auth_url($base_url), 'auth_url()');
27 eval { $client->auth_by_code("blah", $base_url) };
28 ok($@, "auth_by_code() dies with bogus credentials");
30 skip "No exception", 1 unless $@;
31 my $error_message = $client->error_message($@);
32 ok($error_message =~ m/Authorization Failed/i, "error_message()")
33 or diag("Original:\n$@\nTurned into:\n$error_message");