[Koha-bugs] [Bug 15108] OAI-PMH provider improvements

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Oct 21 08:37:45 CEST 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15108

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcook at prosentient.com.au

--- Comment #43 from David Cook <dcook at prosentient.com.au> ---
(In reply to Marcel de Rooy from comment #42)
> Frederic, the absence of unit tests in this patch set might be a reason for
> these patches getting stuck in the SO queue.

Jonathan just pointed me at this bug...

I've been mocking an OAI server very simply using Test::TCP and
Net::Server::HTTP, so that I can test my OAI client.

The responses are all hard-coded at the moment, and it doesn't check the
incoming requests besides a few verbs, but it's a start. It's 5:33pm on a
Friday here, so I don't have time to flesh this out at the moment.

However, here's the bit of code I'm using:

my $server = Test::TCP->new(
    code => sub {
        my $port = shift;
        Net::Server::HTTP->run(
            log_level => 0,
            port => [$port],
            app => {
                '/' => sub {
                    my ($server) = @_;
                    my $request = $server->http_request_info;
                    my @uri_strings = ();
                    my @uri_string =  map { $_ if defined $_ }
($request->{request_protocol},"://",$request->{request_path},$request->{query_string});
                    my $uri_string = join("", at uri_string);
                    # my $uri_string =
join($request->{request_protocol},"://",$request->{request_path},$request->{query_string});
                    my $uri = URI->new($uri_string);
                    my %query_parameters = $uri->query_form;
                    print "Content-type: text/xml\n\n";
                    if (%query_parameters){
                        if ($query_parameters{verb} eq "Identify"){
                            print "$identify_xml\n";
                        }
                        elsif ($query_parameters{verb} eq "GetRecord"){
                            print "$getrecord_xml\n";
                        }
                        elsif ($query_parameters{verb} eq "ListRecords"){
                            print "$listrecords_xml\n";
                        }
                    }
                    else {
                        print "$error_xml\n";
                    }
                },
            },
        );
    },
);

I imagine it should be fairly easy to test the Koha::OAI::Server modules by
building off this pattern. 

Call $server->port to get the port to which the test server has bound, and
you're able to connect to the server using localhost.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list