diff options
author | Struan Donald <struan@exo.org.uk> | 2018-06-08 11:37:26 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-06-08 14:17:33 +0100 |
commit | ee64aab278b76c69436a560e05242a833c1b7d6d (patch) | |
tree | fcb657c9f7b3bd5fd3c6bff608d906387720938e /t/open311 | |
parent | bb5a526e700d9f9f4568a0defc0241d7999f79ee (diff) |
[Oxfordshire] use localtime in open311 get update call
As Oxfordshire uses local time and not UTC use that when calling the get
update script. Also handle a date with a timezone being passed on the
server side.
And add some tests in for the oxfordshire open311 endpoint
Fixes mysociety/fixmystreet-commercial#1062
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/oxfordshire/open311_services.t | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/open311/oxfordshire/open311_services.t b/t/open311/oxfordshire/open311_services.t new file mode 100644 index 000000000..c12ce9f43 --- /dev/null +++ b/t/open311/oxfordshire/open311_services.t @@ -0,0 +1,37 @@ +use FixMyStreet::Test; +use POSIX qw(tzset); + +my $d; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + $d = dirname(File::Spec->rel2abs(__FILE__)); +} + +use lib "$d/../../../bin/oxfordshire"; + +use_ok 'open311_services'; + +my $old_tz = $ENV{TZ}; +$ENV{TZ} = 'Europe/London'; +tzset; + +is get_utc_iso8601_string('2018-06-01 13:37:42'), '2018-06-01T12:37:42Z', 'convert local to iso UTC'; + +is get_date_or_nothing('2018-06-01T12:37:42Z'), '2018-06-01 12:37:42', 'convert date format'; +is get_date_or_nothing('2018-06-01T12:37Z'), '2018-06-01 12:37:00', 'convert date format add seconds'; +is get_date_or_nothing('2018-06-01T12:37:42Z', 1), '2018-06-01', 'convert date format and ignore time'; +is get_date_or_nothing('2018/06/01 12:37:42'), '', 'convert date returns nothing if no match'; + +is get_date_or_nothing('2018-06-07T12:35:08+01:00'), '2018-06-07 12:35:08', 'convert date format with TZ'; + +$ENV{TZ} = 'Europe/Rome'; +tzset; + +is get_utc_iso8601_string('2018-06-01 14:37:42'), '2018-06-01T12:37:42Z', 'convert local to iso UTC alt TZ'; + +$ENV{TZ} = $old_tz; +tzset; + +done_testing(); |