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.
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.