diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/MapIt.pm | 1 | ||||
-rw-r--r-- | t/open311/getservicerequests.t | 69 |
2 files changed, 70 insertions, 0 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 7429d9731..c255c916a 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -39,6 +39,7 @@ my @PLACES = ( [ 'BR1 3UH', 51.402096, 0.015784, 2482, 'Bromley Council', 'LBO' ], [ 'NN1 1NS', 52.236251, 0.892052, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ], [ 'NN1 2NS', 52.238301, 0.889992, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ], + [ 'TW7 5JN', 51.482286, -0.328163, 2483, 'Hounslow Borough Council', 'LBO' ], [ '?', 50.78301, -0.646929 ], [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ], [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], 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({ |