The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Dochazka::REST::Test - Test helper functions

DESCRIPTION

This module provides helper code for unit tests.

EXPORTS

PACKAGE VARIABLES

FUNCTIONS

initialize_unit

Perform the boilerplate tasks that have to be done at the beginning of every unit that accesses the REST server and/or the database.

status_from_json

App::Dochazka::REST is designed to return status objects in the HTTP response body. These, of course, are sent in JSON format. This simple routine takes a JSON string and blesses it, thereby converting it back into a status object.

FIXME: There may be some encoding issues here!

req

Assemble and process a HTTP request. Takes the following positional arguments:

    * Plack::Test object
    * expected HTTP result code
    * user to authenticate with (can be 'root', 'demo', or 'active')
    * HTTP method
    * resource string
    * optional JSON string

If the HTTP result code is 200, the return value will be a status object, undef otherwise.

dbi_err

Wrapper for 'req' intended to eliminate duplicated code on tests that are expected to return DOCHAZKA_DBI_ERR. In addition to the arguments expected by 'req', takes one additional argument, which should be:

    qr/error message subtext/

(i.e. a regex quote by which to test the $status->text)

docu_check

Check that the resource has on-line documentation (takes Plack::Test object and resource name without quotes)

create_testing_employee

Tests will need to set up and tear down testing employees

create_active_employee

Create testing employee with 'active' privilege

create_inactive_employee

Create testing employee with 'active' privilege

delete_testing_employee

Tests will need to set up and tear down testing employees (takes EID)

delete_employee_by_nick

Delete testing employee (takes Plack::Test object and nick)

create_testing_activity

Tests will need to set up and tear down testing activities

delete_testing_activity

Tests will need to set up and tear down testing activities

create_testing_schedule

Tests will need to set up and tear down testing schedules. Takes a Plack::Test object as its only argument.

delete_testing_schedule

Tests will need to set up and tear down testing schedule. Takes a SID as its only argument.