diff options
author | Dave Arter <davea@mysociety.org> | 2019-04-12 16:04:49 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2019-06-04 14:54:50 +0100 |
commit | 6da4f2a979a87e82360ce024a9630f7194684718 (patch) | |
tree | d725662d5e72db7473cf1e8a9373a5feaf7a6bcf /t/open311 | |
parent | 0d67c672ca10538695eadd48c406e2707ea9c5c6 (diff) |
[Hounslow] Don't fetch non_public reports at all from Open311
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/getservicerequests.t | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t index 01613cb58..c44be5099 100644 --- a/t/open311/getservicerequests.t +++ b/t/open311/getservicerequests.t @@ -17,6 +17,9 @@ my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Sidew my $body2 = $mech->create_body_ok(2217, 'Buckinghamshire'); my $contact2 = $mech->create_contact_ok( body_id => $body2->id, category => 'Sidewalk and Curb Issues', email => 'sidewalks' ); +my $hounslow = $mech->create_body_ok(2483, 'Hounslow'); +my $hounslowcontact = $mech->create_contact_ok( body_id => $hounslow->id, category => 'Sidewalk and Curb Issues', email => 'sidewalks' ); + my $dtf = DateTime::Format::W3CDTF->new; my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?> @@ -469,6 +472,72 @@ for my $test ( }; } +my $hounslow_non_public_xml = qq[<?xml version="1.0" encoding="utf-8"?> +<service_requests> +<request> +<service_request_id>123456</service_request_id> +<status>open</status> +<status_notes></status_notes> +<service_name>Sidewalk and Curb Issues</service_name> +<service_code>sidewalks</service_code> +<description>this is a problem</description> +<agency_responsible></agency_responsible> +<service_notice></service_notice> +<requested_datetime>2010-04-14T06:37:38-08:00</requested_datetime> +<updated_datetime>2010-04-14T06:37:38-08:00</updated_datetime> +<expected_datetime>2010-04-15T06:37:38-08:00</expected_datetime> +<lat>51.482286</lat> +<long>-0.328163</long> +<non_public>1</non_public> +</request> +</service_requests> +]; + +for my $test ( + { + desc => 'Hounslow non_public reports not created', + non_public => 1, + count => 0, + }, + { + desc => 'Hounslow public reports are created', + non_public => 0, + count => 1, + }, +) { + subtest $test->{desc} => sub { + (my $xml = $hounslow_non_public_xml) =~ s/non_public>1/non_public>$test->{non_public}/; + + my $o = Open311->new( + jurisdiction => 'mysociety', + endpoint => 'http://example.com', + test_mode => 1, + test_get_returns => { 'requests.xml' => $xml} + ); + + my $update = Open311::GetServiceRequests->new( + system_user => $user, + start_date => $start_date, + end_date => $end_date + ); + + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => [ 'hounslow' ], + }, sub { + $update->create_problems( $o, $hounslow ); + }; + + my $q = FixMyStreet::DB->resultset('Problem')->search( + { external_id => 123456 } + ); + + is $q->count, $test->{count}, 'problem count is correct'; + + $q->first->delete if $test->{count}; + }; +} + subtest "non_public contacts result in non_public reports" => sub { $contact->update({ |