aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311
diff options
context:
space:
mode:
Diffstat (limited to 't/open311')
-rw-r--r--t/open311/getservicerequestupdates.t237
-rw-r--r--t/open311/getupdates.t85
-rw-r--r--t/open311/populate-service-list.t134
3 files changed, 321 insertions, 135 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index aba811e58..00c25a83e 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -13,6 +13,7 @@ use_ok( 'Open311' );
use_ok( 'Open311::GetServiceRequestUpdates' );
use DateTime;
+use DateTime::Format::W3CDTF;
use FixMyStreet::App;
my $user = FixMyStreet::App->model('DB::User')->find_or_create(
@@ -123,7 +124,7 @@ my $problem = $problem_rs->new(
lastupdate => DateTime->now()->subtract( days => 1 ),
anonymous => 1,
external_id => time(),
- council => 2482,
+ bodies_str => 2482,
}
);
@@ -131,71 +132,212 @@ $problem->insert;
for my $test (
{
- desc => 'element with content',
- updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ desc => 'OPEN status for confirmed problem does not change state',
description => 'This is a note',
external_id => 638344,
start_state => 'confirmed',
- close_comment => 0,
+ comment_status => 'OPEN',
mark_fixed=> 0,
mark_open => 0,
problem_state => undef,
end_state => 'confirmed',
},
{
- desc => 'comment closes report',
- updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ desc => 'bad state does not update states but does create update',
description => 'This is a note',
external_id => 638344,
start_state => 'confirmed',
- close_comment => 1,
+ comment_status => 'INVALID_STATE',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => undef,
+ end_state => 'confirmed',
+ },
+
+ {
+ desc => 'investigating status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'INVESTIGATING',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'investigating',
+ end_state => 'investigating',
+ },
+ {
+ desc => 'in progress status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'IN_PROGRESS',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'in progress',
+ end_state => 'in progress',
+ },
+ {
+ desc => 'action scheduled status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'ACTION_SCHEDULED',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'action scheduled',
+ end_state => 'action scheduled',
+ },
+ {
+ desc => 'not responsible status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'NOT_COUNCILS_RESPONSIBILITY',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'not responsible',
+ end_state => 'not responsible',
+ },
+ {
+ desc => 'internal referral status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'INTERNAL_REFERRAL',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'internal referral',
+ end_state => 'internal referral',
+ },
+ {
+ desc => 'duplicate status changes problem status',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'DUPLICATE',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'duplicate',
+ end_state => 'duplicate',
+ },
+ {
+ desc => 'fixed status marks report as fixed - council',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'FIXED',
mark_fixed=> 0,
mark_open => 0,
problem_state => 'fixed - council',
end_state => 'fixed - council',
},
{
- desc => 'comment re-opens fixed report',
- updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ desc => 'status of CLOSED marks report as fixed - council',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'CLOSED',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'fixed - council',
+ end_state => 'fixed - council',
+ },
+ {
+ desc => 'status of OPEN re-opens fixed report',
description => 'This is a note',
external_id => 638344,
start_state => 'fixed - user',
- close_comment => 0,
+ comment_status => 'OPEN',
mark_fixed => 0,
mark_open => 0,
problem_state => 'confirmed',
end_state => 'confirmed',
},
{
- desc => 'comment re-opens closed report',
- updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ desc => 'action sheduled re-opens fixed report as action scheduled',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'fixed - user',
+ comment_status => 'ACTION_SCHEDULED',
+ mark_fixed => 0,
+ mark_open => 0,
+ problem_state => 'action scheduled',
+ end_state => 'action scheduled',
+ },
+ {
+ desc => 'open status re-opens closed report',
description => 'This is a note',
external_id => 638344,
- start_state => 'closed',
- close_comment => 0,
+ start_state => 'not responsible',
+ comment_status => 'OPEN',
mark_fixed => 0,
mark_open => 0,
problem_state => 'confirmed',
end_state => 'confirmed',
},
{
- desc => 'comment leaves report closed',
- updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ desc => 'fixed status leaves fixed - user report as fixed - user',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'fixed - user',
+ comment_status => 'FIXED',
+ mark_fixed => 0,
+ mark_open => 0,
+ problem_state => undef,
+ end_state => 'fixed - user',
+ },
+ {
+ desc => 'closed status updates fixed report',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'fixed - user',
+ comment_status => 'NO_FURTHER_ACTION',
+ mark_fixed => 0,
+ mark_open => 0,
+ problem_state => 'unable to fix',
+ end_state => 'unable to fix',
+ },
+ {
+ desc => 'no futher action status closes report',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'NO_FURTHER_ACTION',
+ mark_fixed => 0,
+ mark_open => 0,
+ problem_state => 'unable to fix',
+ end_state => 'unable to fix',
+ },
+ {
+ desc => 'fixed status sets closed report as fixed',
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'unable to fix',
+ comment_status => 'FIXED',
+ mark_fixed => 0,
+ mark_open => 0,
+ problem_state => 'fixed - council',
+ end_state => 'fixed - council',
+ },
+ {
+ desc => 'open status does not re-open hidden report',
description => 'This is a note',
external_id => 638344,
- start_state => 'closed',
- close_comment => 1,
+ start_state => 'hidden',
+ comment_status => 'OPEN',
mark_fixed => 0,
mark_open => 0,
- end_state => 'closed',
+ problem_state => 'confirmed',
+ end_state => 'hidden',
},
) {
subtest $test->{desc} => sub {
my $local_requests_xml = $requests_xml;
- $local_requests_xml =~ s/UPDATED_DATETIME/$test->{updated_datetime}/;
+ my $updated_datetime = sprintf( '<updated_datetime>%s</updated_datetime>', $dt );
+ $local_requests_xml =~ s/UPDATED_DATETIME/$updated_datetime/;
$local_requests_xml =~ s#<service_request_id>\d+</service_request_id>#<service_request_id>@{[$problem->external_id]}</service_request_id>#;
$local_requests_xml =~ s#<service_request_id_ext>\d+</service_request_id_ext>#<service_request_id_ext>@{[$problem->id]}</service_request_id_ext>#;
- $local_requests_xml =~ s#<status>\w+</status>#<status>closed</status># if $test->{close_comment};
+ $local_requests_xml =~ s#<status>\w+</status>#<status>$test->{comment_status}</status># if $test->{comment_status};
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } );
@@ -204,7 +346,7 @@ for my $test (
$problem->state( $test->{start_state} );
$problem->update;
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -234,7 +376,8 @@ foreach my $test (
$dt->subtract( minutes => 10 );
my $local_requests_xml = $requests_xml;
- my $updated = sprintf( '<updated_datetime>%s</updated_datetime>', $dt );
+ my $updated = sprintf( '<updated_datetime>%s</updated_datetime>', DateTime::Format::W3CDTF->format_datetime( $dt ) );
+
$local_requests_xml =~ s/UPDATED_DATETIME/$updated/;
$local_requests_xml =~ s#<service_request_id>\d+</service_request_id>#<service_request_id>@{[$problem->external_id]}</service_request_id>#;
$local_requests_xml =~ s#<service_request_id_ext>\d+</service_request_id_ext>#<service_request_id_ext>@{[$problem->id]}</service_request_id_ext>#;
@@ -243,7 +386,7 @@ foreach my $test (
$problem->comments->delete;
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -273,7 +416,7 @@ my $problem2 = $problem_rs->new(
lastupdate => DateTime->now(),
anonymous => 1,
external_id => $problem->external_id,
- council => 2651,
+ bodies_str => 2651,
}
);
@@ -312,7 +455,7 @@ for my $test (
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } );
- my $council_details = { areaid => $test->{area_id} };
+ my $council_details = { areas => { $test->{area_id} => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -352,7 +495,7 @@ subtest 'using start and end date' => sub {
end_date => $end_dt,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
my $start = $start_dt . '';
@@ -412,7 +555,7 @@ subtest 'check that existing comments are not duplicated' => sub {
system_user => $user,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
@@ -473,7 +616,7 @@ foreach my $test ( {
system_user => $user,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
@@ -484,10 +627,22 @@ foreach my $test ( {
foreach my $test ( {
desc => 'normally alerts are not suppressed',
+ num_alerts => 1,
suppress_alerts => 0,
},
{
desc => 'alerts suppressed if suppress_alerts set',
+ num_alerts => 1,
+ suppress_alerts => 1,
+ },
+ {
+ desc => 'alert suppression ok even if no alerts',
+ num_alerts => 0,
+ suppress_alerts => 1,
+ },
+ {
+ desc => 'alert suppression ok even if 2x alerts',
+ num_alerts => 2,
suppress_alerts => 1,
}
) {
@@ -509,12 +664,14 @@ foreach my $test ( {
$problem->lastupdate( $dt->subtract( hours => 3 ) );
$problem->update;
- my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create( {
- alert_type => 'new_updates',
- parameter => $problem->id,
- confirmed => 1,
- user_id => $problem->user->id,
- } );
+ my @alerts = map {
+ my $alert = FixMyStreet::App->model('DB::Alert')->create( {
+ alert_type => 'new_updates',
+ parameter => $problem->id,
+ confirmed => 1,
+ user_id => $problem->user->id,
+ } )
+ } (1..$test->{num_alerts});
$requests_xml =~ s/UPDATED_DATETIME/$dt/;
@@ -525,25 +682,27 @@ foreach my $test ( {
suppress_alerts => $test->{suppress_alerts},
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->search(
{
- alert_id => $alert->id,
+ alert_id => [ map $_->id, @alerts ],
parameter => $problem->comments->first->id,
}
);
if ( $test->{suppress_alerts} ) {
- ok $alerts_sent->count(), 'alerts suppressed';
+ is $alerts_sent->count(), $test->{num_alerts}, 'alerts suppressed';
} else {
is $alerts_sent->count(), 0, 'alerts not suppressed';
}
$alerts_sent->delete;
- $alert->delete;
+ for my $alert (@alerts) {
+ $alert->delete;
+ }
}
}
diff --git a/t/open311/getupdates.t b/t/open311/getupdates.t
index 500ac97d2..7dc7ff164 100644
--- a/t/open311/getupdates.t
+++ b/t/open311/getupdates.t
@@ -4,9 +4,7 @@ use strict;
use warnings;
use Test::More;
-use FindBin;
-use lib "$FindBin::Bin/../perllib";
-use lib "$FindBin::Bin/../commonlib/perllib";
+use FixMyStreet;
use_ok( 'Open311::GetUpdates' );
use_ok( 'Open311' );
@@ -17,6 +15,9 @@ my $user = FixMyStreet::App->model('DB::User')->find_or_create(
}
);
+my $body = FixMyStreet::App->model('DB::Body')->new( {
+ name => 'Test Body',
+} );
my $updates = Open311::GetUpdates->new( system_user => $user );
ok $updates, 'created object';
@@ -51,12 +52,9 @@ my $problem = $problem_rs->new(
title => '',
detail => '',
used_map => 1,
- user_id => 1,
name => '',
state => 'confirmed',
- service => '',
cobrand => 'default',
- cobrand_data => '',
user => $user,
created => DateTime->now()->subtract( days => 1 ),
lastupdate => DateTime->now()->subtract( days => 1 ),
@@ -104,7 +102,7 @@ for my $test (
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } );
- ok $updates->update_reports( [ 638344 ], $o, { name => 'Test Council' } );
+ ok $updates->update_reports( [ 638344 ], $o, $body );
is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344', 'get url';
is $problem->comments->count, $test->{comment_count}, 'added a comment';
@@ -155,12 +153,9 @@ my $problem2 = $problem_rs->create(
title => '',
detail => '',
used_map => 1,
- user_id => 1,
name => '',
state => 'confirmed',
- service => '',
cobrand => 'default',
- cobrand_data => '',
user => $user,
created => DateTime->now()->subtract( days => 1 ),
lastupdate => DateTime->now()->subtract( days => 1 ),
@@ -182,17 +177,73 @@ subtest 'update with two requests' => sub {
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } );
- ok $updates->update_reports( [ 638344,638345 ], $o, { name => 'Test Council' } );
+ ok $updates->update_reports( [ 638344,638345 ], $o, $body );
is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344%2C638345', 'get url';
is $problem->comments->count, 1, 'added a comment to first problem';
is $problem2->comments->count, 1, 'added a comment to second problem';
};
-$problem->comments->delete;
-$problem->delete;
-$user->comments->delete;
-$user->problems->delete;
-$user->delete;
+# No status_notes field now, so that static string in code is used.
+$requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
+<service_requests>
+<request>
+<service_request_id>638346</service_request_id>
+<status>closed</status>
+<service_name>Sidewalk and Curb Issues</service_name>
+<service_code>006</service_code>
+<description></description>
+<agency_responsible></agency_responsible>
+<service_notice></service_notice>
+<requested_datetime>2010-04-14T06:37:38-08:00</requested_datetime>
+UPDATED_DATETIME
+<expected_datetime>2010-04-15T06:37:38-08:00</expected_datetime>
+<lat>37.762221815</lat>
+<long>-122.4651145</long>
+</request>
+</service_requests>
+};
-done_testing();
+my $problem3 = $problem_rs->create( {
+ postcode => 'EH99 1SP',
+ latitude => 1,
+ longitude => 1,
+ areas => 1,
+ title => 'Title',
+ detail => 'Details',
+ used_map => 1,
+ name => '',
+ state => 'confirmed',
+ cobrand => 'fixamingata',
+ user => $user,
+ created => DateTime->now()->subtract( days => 1 ),
+ lastupdate => DateTime->now()->subtract( days => 1 ),
+ anonymous => 1,
+ external_id => 638346,
+} );
+
+subtest 'test translation of auto-added comment from old-style Open311 update' => sub {
+ my $dt = sprintf( '<updated_datetime>%s</updated_datetime>', DateTime->now );
+ $requests_xml =~ s/UPDATED_DATETIME/$dt/;
+
+ my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $requests_xml } );
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixamingata' ],
+ }, sub {
+ ok $updates->update_reports( [ 638346 ], $o, $body );
+ };
+ is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638346', 'get url';
+
+ is $problem3->comments->count, 1, 'added a comment';
+ is $problem3->comments->first->text, "St\xe4ngd av kommunen", 'correct comment text';
+};
+
+END {
+ if ($user) {
+ $user->comments->delete;
+ $user->problems->delete;
+ $user->delete;
+ }
+ done_testing();
+}
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index 00026cd9f..9fd18b607 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -14,34 +14,44 @@ use_ok( 'Open311::PopulateServiceList' );
use_ok( 'Open311' );
-my $processor = Open311::PopulateServiceList->new( council_list => [] );
+my $processor = Open311::PopulateServiceList->new();
ok $processor, 'created object';
-
+my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
+ id => 1,
+ name => 'Body Numero Uno',
+} );
+$body->body_areas->find_or_create({
+ area_id => 1
+} );
+
+my $bromley = FixMyStreet::App->model('DB::Body')->find_or_create( {
+ id => 2482,
+ name => 'Bromley Council',
+} );
+$bromley->body_areas->find_or_create({
+ area_id => 2482
+} );
subtest 'check basic functionality' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete();
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
- area_id => 1
- } );
-
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ my $processor = Open311::PopulateServiceList->new();
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count();
+ my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check non open311 contacts marked as deleted' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete();
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $contact = FixMyStreet::App->model('DB::Contact')->create(
{
- area_id => 1,
+ body_id => 1,
email => 'contact@example.com',
category => 'An old category',
confirmed => 1,
@@ -54,27 +64,23 @@ subtest 'check non open311 contacts marked as deleted' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
- area_id => 1
- } );
-
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ my $processor = Open311::PopulateServiceList->new();
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count();
+ my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
is $contact_count, 4, 'correct number of contacts';
- $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1, deleted => 1 } )->count();
+ $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1, deleted => 1 } )->count();
is $contact_count, 1, 'correct number of deleted contacts';
};
subtest 'check email changed if matching category' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete();
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $contact = FixMyStreet::App->model('DB::Contact')->create(
{
- area_id => 1,
+ body_id => 1,
email => '009',
category => 'Cans left out 24x7',
confirmed => 1,
@@ -89,12 +95,8 @@ subtest 'check email changed if matching category' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
- area_id => 1
- } );
-
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ my $processor = Open311::PopulateServiceList->new();
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -102,16 +104,16 @@ subtest 'check email changed if matching category' => sub {
is $contact->confirmed, 1, 'contact still confirmed';
is $contact->deleted, 0, 'contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count();
+ my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check category name changed if updated' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete();
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $contact = FixMyStreet::App->model('DB::Contact')->create(
{
- area_id => 1,
+ body_id => 1,
email => '001',
category => 'Bins left out 24x7',
confirmed => 1,
@@ -126,12 +128,8 @@ subtest 'check category name changed if updated' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
- area_id => 1
- } );
-
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ my $processor = Open311::PopulateServiceList->new();
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -140,16 +138,16 @@ subtest 'check category name changed if updated' => sub {
is $contact->confirmed, 1, 'contact still confirmed';
is $contact->deleted, 0, 'contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count();
+ my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check conflicting contacts not changed' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->delete();
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $contact = FixMyStreet::App->model('DB::Contact')->create(
{
- area_id => 1,
+ body_id => 1,
email => 'existing@example.com',
category => 'Cans left out 24x7',
confirmed => 1,
@@ -164,7 +162,7 @@ subtest 'check conflicting contacts not changed' => sub {
my $contact2 = FixMyStreet::App->model('DB::Contact')->create(
{
- area_id => 1,
+ body_id => 1,
email => '001',
category => 'Bins left out 24x7',
confirmed => 1,
@@ -179,12 +177,8 @@ subtest 'check conflicting contacts not changed' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
- area_id => 1
- } );
-
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ my $processor = Open311::PopulateServiceList->new();
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -199,12 +193,12 @@ subtest 'check conflicting contacts not changed' => sub {
is $contact2->confirmed, 1, 'second contact contact still confirmed';
is $contact2->deleted, 0, 'second contact contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { area_id => 1 } )->count();
+ my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
is $contact_count, 4, 'correct number of contacts';
};
subtest 'check meta data population' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
@@ -225,7 +219,7 @@ subtest 'check meta data population' => sub {
my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
{
- area_id => 1,
+ body_id => 1,
email => '001',
category => 'Bins left out 24x7',
confirmed => 1,
@@ -243,12 +237,8 @@ subtest 'check meta data population' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
- area_id => 2482
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $bromley );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -387,7 +377,7 @@ for my $test (
},
) {
subtest $test->{desc} => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $services_xml = '<?xml version="1.0" encoding="utf-8"?>
<services>
@@ -409,7 +399,7 @@ for my $test (
my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
{
- area_id => 1,
+ body_id => 1,
email => '100',
category => 'Cans left out 24x7',
confirmed => 1,
@@ -432,12 +422,8 @@ for my $test (
my $service_list = get_xml_simple_object( $services_xml );
$service_list = { service => [ $service_list->{ service } ] };
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
- area_id => 1
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -448,7 +434,7 @@ for my $test (
}
subtest 'check attribute ordering' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
@@ -487,7 +473,7 @@ subtest 'check attribute ordering' => sub {
my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
{
- area_id => 1,
+ body_id => 1,
email => '001',
category => 'Bins left out 24x7',
confirmed => 1,
@@ -505,12 +491,8 @@ subtest 'check attribute ordering' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
- area_id => 1
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -554,7 +536,7 @@ subtest 'check attribute ordering' => sub {
};
subtest 'check bromely skip code' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
@@ -593,7 +575,7 @@ subtest 'check bromely skip code' => sub {
my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
{
- area_id => 1,
+ body_id => 1,
email => '001',
category => 'Bins left out 24x7',
confirmed => 1,
@@ -611,12 +593,8 @@ subtest 'check bromely skip code' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
- area_id => 2482
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $bromley );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -636,9 +614,7 @@ subtest 'check bromely skip code' => sub {
is_deeply $contact->extra, $extra, 'only non std bromley meta data saved';
- $council->area_id(1);
-
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->_add_meta_to_contact( $contact );
$extra = [