diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-06-29 15:00:55 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-11-11 10:28:23 +0000 |
commit | ce1b3ec61fdaa954c26e55b8ce8cd1ad619b3538 (patch) | |
tree | 3ab20e43f6bf6b4a0ca1284c019a26f5fe7a2ef5 /t | |
parent | 9292866fbc1be364a716ac9efb105a0350a2de72 (diff) |
[Bromley] Add waste service lookup.
This creates an integration to view bin collection days, and
placeholders for the start of a non-map property-based reporting flow.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/waste.t | 53 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 62 |
2 files changed, 53 insertions, 62 deletions
diff --git a/t/app/controller/waste.t b/t/app/controller/waste.t new file mode 100644 index 000000000..77b1ef5bc --- /dev/null +++ b/t/app/controller/waste.t @@ -0,0 +1,53 @@ +use Test::MockModule; +use FixMyStreet::TestMech; + +my $mech = FixMyStreet::TestMech->new; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => ['bromley', 'fixmystreet'], + COBRAND_FEATURES => { echo => { bromley => { sample_data => 1 } }, waste => { bromley => 1 } }, +}, sub { + $mech->host('bromley.fixmystreet.com'); + subtest 'Missing address lookup' => sub { + $mech->get_ok('/waste'); + $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); + $mech->submit_form_ok({ with_fields => { address => 'missing' } }); + $mech->content_contains('can’t find your address'); + }; + subtest 'Address lookup' => sub { + $mech->get_ok('/waste'); + $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); + $mech->submit_form_ok({ with_fields => { address => '1000000002' } }); + $mech->content_contains('2 Example Street'); + $mech->content_contains('Food Waste'); + }; +}; + +package SOAP::Result; +sub result { return $_[0]->{result}; } +sub new { my $c = shift; bless { @_ }, $c; } + +package main; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => 'bromley', + COBRAND_FEATURES => { echo => { bromley => { url => 'http://example.org' } }, waste => { bromley => 1 } }, +}, sub { + subtest 'Address lookup, mocking SOAP call' => sub { + my $integ = Test::MockModule->new('SOAP::Lite'); + $integ->mock(call => sub { + return SOAP::Result->new(result => { + PointInfo => [ + { Description => '1 Example Street', SharedRef => { Value => { anyType => 1000000001 } } }, + { Description => '2 Example Street', SharedRef => { Value => { anyType => 1000000002 } } }, + ], + }); + }); + + $mech->get_ok('/waste'); + $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); + $mech->content_contains('2 Example Street'); + }; +}; + +done_testing; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index e6fa8e115..d26b10709 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -242,66 +242,4 @@ subtest 'check heatmap page' => sub { }; }; -package SOAP::Result; -sub result { return $_[0]->{result}; } -sub new { my $c = shift; bless { @_ }, $c; } - -package main; - -subtest 'updating of waste reports' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => 'bromley', - COBRAND_FEATURES => { - echo => { bromley => { - receive_action => 'action', - receive_username => 'un', - receive_password => 'password', - } }, - waste => { bromley => 1 } - }, - }, sub { - FixMyStreet::App->log->disable('info'); - - $mech->get('/waste/echo'); - is $mech->res->code, 405, 'Cannot GET'; - - $mech->post('/waste/echo', Content_Type => 'text/xml'); - is $mech->res->code, 400, 'No body'; - - my $in = '<Envelope><Header><Action>bad-action</Action></Header><Body></Body></Envelope>'; - $mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in); - is $mech->res->code, 400, 'Bad action'; - - $in = '<Envelope><Header><Action>action</Action><Security><UsernameToken><Username></Username><Password></Password></UsernameToken></Security></Header><Body></Body></Envelope>'; - $mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in); - is $mech->res->code, 400, 'Bad auth'; - - $in = <<EOF; -<?xml version="1.0" encoding="UTF-8"?> -<Envelope> - <Header> - <Action>action</Action> - <Security><UsernameToken><Username>un</Username><Password>password</Password></UsernameToken></Security> - </Header> - <Body> - <NotifyEventUpdated> - <event> - <Guid>waste-15005-XXX</Guid> - <EventTypeId>2104</EventTypeId> - <EventStateId>15006</EventStateId> - <ResolutionCodeId>207</ResolutionCodeId> - </event> - </NotifyEventUpdated> - </Body> -</Envelope> -EOF - - $mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in); - is $mech->res->code, 200, 'OK response, even though event does not exist'; - is $report->comments->count, 2, 'No new update'; - - FixMyStreet::App->log->enable('info'); - }; -}; - done_testing(); |