diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-04-26 12:16:26 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-04-26 13:41:18 +0100 |
commit | 810759ae13d7dca1b16f36841ca7d364c1738cb5 (patch) | |
tree | 64c4691165ed502eb9e2e81584fb2571974edbd1 /t | |
parent | 0246627c929f700a46c5065ac1f70fe14aa1ac03 (diff) |
Skip fetched updates if they're out of date range.
Even when we ask for a specific range of dates, we sometimes get given
more in the response.
Diffstat (limited to 't')
-rw-r--r-- | t/open311/getservicerequestupdates.t | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index a57d2d0e6..134d5422e 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -38,7 +38,7 @@ UPDATED_DATETIME }; -my $dt = DateTime->now; +my $dt = DateTime->now(formatter => DateTime::Format::W3CDTF->new); # basic xml -> perl object tests for my $test ( @@ -571,7 +571,8 @@ subtest 'check that existing comments are not duplicated' => sub { is $problem->comments->count, 1, 'one comment before fetching updates'; $requests_xml =~ s/UPDATED_DATETIME2/$dt/; - $requests_xml =~ s/UPDATED_DATETIME/@{[ $comment->confirmed ]}/; + my $confirmed = DateTime::Format::W3CDTF->format_datetime($comment->confirmed); + $requests_xml =~ s/UPDATED_DATETIME/$confirmed/; my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $requests_xml } ); @@ -596,12 +597,12 @@ subtest 'check that existing comments are not duplicated' => sub { foreach my $test ( { desc => 'check that closed and then open comment results in correct state', - dt1 => $dt->subtract( hours => 1 ), + dt1 => $dt->clone->subtract( hours => 1 ), dt2 => $dt, }, { desc => 'check that old comments do not change problem status', - dt1 => $dt->subtract( hours => 2 ), + dt1 => $dt->clone->subtract( minutes => 90 ), dt2 => $dt, } ) { @@ -627,7 +628,7 @@ foreach my $test ( { $problem->comments->delete; $problem->state( 'confirmed' ); - $problem->lastupdate( $dt->subtract( hours => 3 ) ); + $problem->lastupdate( $dt->clone->subtract( hours => 3 ) ); $problem->update; $requests_xml =~ s/UPDATED_DATETIME/$test->{dt1}/; @@ -683,7 +684,7 @@ foreach my $test ( { $problem->comments->delete; $problem->state( 'confirmed' ); - $problem->lastupdate( $dt->subtract( hours => 3 ) ); + $problem->lastupdate( $dt->clone->subtract( hours => 3 ) ); $problem->update; my @alerts = map { |