Summary: | Refactor REST API session mocking to reduce code duplication | ||
---|---|---|---|
Product: | Koha | Reporter: | Olli-Antti Kivilahti <olli-antti.kivilahti> |
Component: | REST API | Assignee: | Bugs List <koha-bugs> |
Status: | CLOSED WORKSFORME | QA Contact: | |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | m.de.rooy, tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19512 | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Bug Depends on: | 14539, 19512 | ||
Bug Blocks: | |||
Attachments: | Bug 19515 - Refactor REST API session mocking to reduce ridiculous amounts of duplication |
Description
Olli-Antti Kivilahti
2017-10-23 12:29:20 UTC
Created attachment 68390 [details] [review] Bug 19515 - Refactor REST API session mocking to reduce ridiculous amounts of duplication The amount of duplication in REST API tests is beyond anything. I must be hallucinating. This adds a t::lib::Mocks::mock_session() which mocks a session reverting to defaults, and checks CGI::Session->flush for errors. Please, stop this bad dream. Nice title (In reply to Marcel de Rooy from comment #3) > Nice title Hi Olli, good innitiative. Just some remarks: - You patch covers several endpoints not currently in master, so it won't apply. - It is way too much to make it dependent on the castToObject stuff, just a personal opinion: you can just my $patron = $builder->build_object({class=>'Koha::Patrons'}); to get a sample patron. This is already in master... - You are missing something that's important for testing: we need to be able to assign the patron specific permissions, something in the lines of: my $flags = ( $args->{authorized} ) ? 2**$args->{authorized} : 0; > - You are missing something that's important for testing: we need to be able > to assign the patron specific permissions, something in the lines of: > my $flags = ( $args->{authorized} ) ? 2**$args->{authorized} : 0; About this, this has been wrong in all submitted tests. I've implemented it correctly in bug 7317. We have implemented Basic authentication, and it got really simple to test the API without this much trouble. |