App::Dochazka::REST::Test - Test helper functions
This module provides helper code for unit tests.
Perform the boilerplate tasks that have to be done at the beginning of every unit that accesses the REST server and/or the database.
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!
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.
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)
Check that the resource has on-line documentation (takes Plack::Test object and resource name without quotes)
Tests will need to set up and tear down testing employees
Create testing employee with 'active' privilege
Tests will need to set up and tear down testing employees (takes EID)
Delete testing employee (takes Plack::Test object and nick)
Tests will need to set up and tear down testing activities
Tests will need to set up and tear down testing schedules. Takes a Plack::Test object as its only argument.
Tests will need to set up and tear down testing schedule. Takes a SID as its only argument.
To install App::Dochazka::REST, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Dochazka::REST
CPAN shell
perl -MCPAN -e shell install App::Dochazka::REST
For more information on module installation, please visit the detailed CPAN module installation guide.