diff options
Diffstat (limited to 't/open311/endpoint')
-rw-r--r-- | t/open311/endpoint/Endpoint1.pm | 114 | ||||
-rw-r--r-- | t/open311/endpoint/Endpoint2.pm | 25 | ||||
-rw-r--r-- | t/open311/endpoint/Endpoint_Warwick.pm | 31 | ||||
-rw-r--r-- | t/open311/endpoint/ServiceType1.pm | 10 | ||||
-rw-r--r-- | t/open311/endpoint/config1.yml | 1 | ||||
-rw-r--r-- | t/open311/endpoint/configfile.t | 23 | ||||
-rw-r--r-- | t/open311/endpoint/exor/DBD/Oracle.pm | 8 | ||||
-rw-r--r-- | t/open311/endpoint/mysociety.t | 160 | ||||
-rw-r--r-- | t/open311/endpoint/schema.t | 82 | ||||
-rw-r--r-- | t/open311/endpoint/spark.t | 62 | ||||
-rw-r--r-- | t/open311/endpoint/warwick.t | 443 | ||||
-rw-r--r-- | t/open311/endpoint/warwick_dbd.t | 17 |
12 files changed, 0 insertions, 976 deletions
diff --git a/t/open311/endpoint/Endpoint1.pm b/t/open311/endpoint/Endpoint1.pm deleted file mode 100644 index ae12172b8..000000000 --- a/t/open311/endpoint/Endpoint1.pm +++ /dev/null @@ -1,114 +0,0 @@ -package t::open311::endpoint::Endpoint1; -use Web::Simple; -extends 'Open311::Endpoint'; -use Types::Standard ':all'; -use MooX::HandlesVia; - -use Open311::Endpoint::Service; -use t::open311::endpoint::ServiceType1; -use Open311::Endpoint::Service::Attribute; -use Open311::Endpoint::Service::Request; - -sub services { - return ( - t::open311::endpoint::ServiceType1->new( - service_code => 'POT', - service_name => 'Pothole Repairs', - description => 'Pothole Repairs Service', - attributes => [ - Open311::Endpoint::Service::Attribute->new( - code => 'depth', - required => 1, - datatype => 'number', - datatype_description => 'an integer', - description => 'depth of pothole, in centimetres', - ), - Open311::Endpoint::Service::Attribute->new( - code => 'shape', - required => 0, - datatype => 'singlevaluelist', - datatype_description => 'square | circle | triangle', - description => 'shape of the pothole', - values => { - square => 'Square', - circle => 'Circle', - triangle => 'Triangle', - }, - ), - ], - type => 'realtime', - keywords => [qw/ deep hole wow/], - group => 'highways', - ), - t::open311::endpoint::ServiceType1->new( - service_code => 'BIN', - service_name => 'Bin Enforcement', - description => 'Bin Enforcement Service', - attributes => [], - type => 'realtime', - keywords => [qw/ bin /], - group => 'sanitation', - ) - ); -} - -# FOR TESTING, we'll just maintain requests in a *global* array... -# obviously a real Service driver will use a DB or API call! -{ - our @SERVICE_REQUESTS; - has _requests => ( - is => 'ro', - isa => ArrayRef[ InstanceOf[ 'Open311::Endpoint::Service::Request' ] ], - default => sub { \@SERVICE_REQUESTS }, - handles_via => 'Array', - handles => { - next_request_id => 'count', - _add_request => 'push', - get_request => 'get', - get_requests => 'elements', - filter_requests => 'grep', - } - ); -} - -sub post_service_request { - my ($self, $service, $args) = @_; - - my $request = $self->new_request( - - # NB: possible race condition between next_request_id and _add_request - # (this is fine for synchronous test-cases) - - service => $service, - service_request_id => $self->next_request_id, - status => 'open', - description => $args->{description}, - agency_responsible => '', - requested_datetime => DateTime->now(), - updated_datetime => DateTime->now(), - address => $args->{address_string} // '', - address_id => $args->{address_id} // '', - media_url => $args->{media_url} // '', - zipcode => $args->{zipcode} // '', - # NB: other info is passed in that would be stored by an Open311 - # endpoint, see Open311::Endpoint::Service::Request for full list, - # but we don't need to handle all of those in this test - ); - $self->_add_request( $request ); - - return ( $request ); -} - -sub get_service_requests { - my ($self, $args) = @_; - - my $service_code = $args->{service_code} or return $self->get_requests; - return $self->filter_requests( sub { my $c = shift->service->service_code; grep { $_ eq $c } @$service_code }); -} - -sub get_service_request { - my ($self, $service_request_id, $args) = @_; - return $self->get_request( $service_request_id ); -} - -1; diff --git a/t/open311/endpoint/Endpoint2.pm b/t/open311/endpoint/Endpoint2.pm deleted file mode 100644 index 664a7f3d6..000000000 --- a/t/open311/endpoint/Endpoint2.pm +++ /dev/null @@ -1,25 +0,0 @@ -package t::open311::endpoint::Endpoint2; -use Web::Simple; -extends 't::open311::endpoint::Endpoint1'; -with 'Open311::Endpoint::Role::mySociety'; - -sub get_service_request_updates { - my ($self, $args) = @_; - - my $start_date = $self->maybe_inflate_datetime($args->{start_date}); - my $end_date = $self->maybe_inflate_datetime($args->{end_date}); - - my @requests = $self->filter_requests( sub { $_[0]->has_updates } ); - - return map { - $_->filter_updates( sub { - my $update = shift; - my $updated_datetime = $update->updated_datetime or return; - if ($start_date) { return unless $updated_datetime >= $start_date } - if ($end_date) { return unless $updated_datetime <= $end_date } - return 1; - }); - } @requests; -} - -1; diff --git a/t/open311/endpoint/Endpoint_Warwick.pm b/t/open311/endpoint/Endpoint_Warwick.pm deleted file mode 100644 index c097f177e..000000000 --- a/t/open311/endpoint/Endpoint_Warwick.pm +++ /dev/null @@ -1,31 +0,0 @@ -package t::open311::endpoint::Endpoint_Warwick; -use Web::Simple; - -our %BINDINGS; -our $UPDATES_SQL; - -extends 'Open311::Endpoint::Integration::Warwick'; - -sub insert_into_db { - my ($self, $bindings) = @_; - - %BINDINGS = %$bindings; - # return ($pem_id, $error_value, $error_product); - return (1001); -} - -sub get_updates_from_sql { - my ($self, $sql) = @_; - $UPDATES_SQL = $sql; - return ( - { - row_id => 999, - service_request_id => 1001, - updated_datetime => '2014-07-23 11:07:00', - status => 'closed', - description => 'Closed the ticket', - } - ); -} - -1; diff --git a/t/open311/endpoint/ServiceType1.pm b/t/open311/endpoint/ServiceType1.pm deleted file mode 100644 index e35e44fda..000000000 --- a/t/open311/endpoint/ServiceType1.pm +++ /dev/null @@ -1,10 +0,0 @@ -package t::open311::endpoint::ServiceType1; -use Moo; -extends 'Open311::Endpoint::Service'; -use DateTime; - -has '+default_service_notice' => ( - default => 'This is a test service', -); - -1; diff --git a/t/open311/endpoint/config1.yml b/t/open311/endpoint/config1.yml deleted file mode 100644 index c444f32c5..000000000 --- a/t/open311/endpoint/config1.yml +++ /dev/null @@ -1 +0,0 @@ -foo: baz diff --git a/t/open311/endpoint/configfile.t b/t/open311/endpoint/configfile.t deleted file mode 100644 index 7f41468ba..000000000 --- a/t/open311/endpoint/configfile.t +++ /dev/null @@ -1,23 +0,0 @@ -use strict; use warnings; - -BEGIN { - package Foo; - use Moo; - with 'Open311::Endpoint::Role::ConfigFile'; - - has foo => ( is => 'ro', default => 'foo' ); -} - -package main; -use Test::More; - -is +Foo->new->foo, - 'foo', 'sanity'; -is +Foo->new( foo => 'bar')->foo, - 'bar', 'override'; -is +Foo->new( config_file => 't/open311/endpoint/config1.yml' )->foo, - 'baz', 'with config'; -is +Foo->new( config_file => 't/open311/endpoint/config1.yml', foo => 'qux' )->foo, - 'qux', 'with config, overridden'; - -done_testing; diff --git a/t/open311/endpoint/exor/DBD/Oracle.pm b/t/open311/endpoint/exor/DBD/Oracle.pm deleted file mode 100644 index d84580d10..000000000 --- a/t/open311/endpoint/exor/DBD/Oracle.pm +++ /dev/null @@ -1,8 +0,0 @@ -package DBD::Oracle; # test -use strict; use warnings; - -sub ORA_DATE () { 2 }; -sub ORA_NUMBER () { 3 } ; -sub ORA_VARCHAR2 () { 5 }; - -1; diff --git a/t/open311/endpoint/mysociety.t b/t/open311/endpoint/mysociety.t deleted file mode 100644 index d0ad60602..000000000 --- a/t/open311/endpoint/mysociety.t +++ /dev/null @@ -1,160 +0,0 @@ -use strict; use warnings; - -use Test::More; -use Test::LongString; -use Test::MockTime ':all'; - -use Open311::Endpoint; -use Data::Dumper; -use JSON::MaybeXS; - -use t::open311::endpoint::Endpoint2; - -my $endpoint = t::open311::endpoint::Endpoint2->new; - -subtest "POST OK" => sub { - diag "Serves as sanity test of subclassing, as well as preparing our data"; - # TODO, refactor repeated code lifted from t/open311/endpoint.t - - set_fixed_time('2014-01-01T12:00:00Z'); - my $res = $endpoint->run_test_request( - POST => '/requests.json', - api_key => 'test', - service_code => 'POT', - address_string => '22 Acacia Avenue', - first_name => 'Bob', - last_name => 'Mould', - 'attribute[depth]' => 100, - 'attribute[shape]' => 'triangle', - ); - ok $res->is_success, 'valid request' - or diag $res->content; - - is_deeply decode_json($res->content), - [ { - "service_notice" => "This is a test service", - "service_request_id" => 0 - } ], 'correct json returned'; - - set_fixed_time('2014-02-01T12:00:00Z'); - $res = $endpoint->run_test_request( - POST => '/requests.xml', - api_key => 'test', - service_code => 'POT', - address_string => '22 Acacia Avenue', - first_name => 'Bob', - last_name => 'Mould', - 'attribute[depth]' => 100, - 'attribute[shape]' => 'triangle', - ); - - ok $res->is_success, 'valid request' - or diag $res->content; -}; - -subtest "GET Service Request Updates" => sub { - - my $empty_xml = <<CONTENT; -<?xml version="1.0" encoding="utf-8"?> -<service_request_updates> -</service_request_updates> -CONTENT - - my $update_0_xml = <<CONTENT; -<?xml version="1.0" encoding="utf-8"?> -<service_request_updates> - <request_update> - <description>Fixed</description> - <media_url></media_url> - <service_request_id>0</service_request_id> - <status>closed</status> - <update_id>1</update_id> - <updated_datetime>2014-01-01T13:00:00Z</updated_datetime> - </request_update> -</service_request_updates> -CONTENT - -my $updates_xml = <<CONTENT; -<?xml version="1.0" encoding="utf-8"?> -<service_request_updates> - <request_update> - <description>Fixed</description> - <media_url></media_url> - <service_request_id>0</service_request_id> - <status>closed</status> - <update_id>1</update_id> - <updated_datetime>2014-01-01T13:00:00Z</updated_datetime> - </request_update> - <request_update> - <description>Have investigated. Looks tricky!</description> - <media_url></media_url> - <service_request_id>1</service_request_id> - <status>open</status> - <update_id>2</update_id> - <updated_datetime>2014-03-01T13:00:00Z</updated_datetime> - </request_update> -</service_request_updates> -CONTENT - - subtest 'No updates' => sub { - my $res = $endpoint->run_test_request( GET => '/servicerequestupdates.xml', ); - ok $res->is_success, 'valid request' or diag $res->content; - - is_string $res->content, $empty_xml, 'xml string ok' - or diag $res->content; - }; - - subtest 'Updated 1 ticket' => sub { - # an agent updates the first ticket - set_fixed_time('2014-01-01T13:00:00Z'); - my $request = $endpoint->get_request(0); - $request->add_update( - update_id => 1, - status => 'closed', - description => 'Fixed', - ); - - is $request->status, 'closed', 'Status updated'; - - my $before='2014-01-01T12:00:00Z'; - my $after ='2014-01-01T14:00:00Z'; - - for my $scenario ( - [ '', $update_0_xml, 'Basic test', ], - [ "?start_date=$before", $update_0_xml, 'start date' ], - [ "?end_date=$after", $update_0_xml, 'end_date' ], - [ "?start_date=$before&end_date=$after", $update_0_xml, 'both dates' ], - [ "?start_date=$after", $empty_xml, 'Not found if start date after update' ], - [ "?end_date=$before", $empty_xml, 'Not found if end date before update' ] - ) { - my ($query, $xml, $description) = @$scenario; - - my $res = $endpoint->run_test_request( GET => '/servicerequestupdates.xml' . $query, ); - ok $res->is_success, 'valid request' or diag $res->content; - is_string $res->content, $xml, $description; - } - }; - - subtest 'Updated another ticket' => sub { - set_fixed_time('2014-03-01T13:00:00Z'); - my $request = $endpoint->get_request(1); - $request->add_update( - update_id => 2, - description => 'Have investigated. Looks tricky!', - ); - - for my $scenario ( - [ '', $updates_xml, 'Both reports', ], - [ "?end_date=2014-01-01T14:00:00Z", $update_0_xml, 'end_date before second update' ], - ) { - my ($query, $xml, $description) = @$scenario; - - my $res = $endpoint->run_test_request( GET => '/servicerequestupdates.xml' . $query, ); - ok $res->is_success, 'valid request' or diag $res->content; - is_string $res->content, $xml, $description or diag $res->content; - } - }; -}; - -restore_time(); -done_testing; diff --git a/t/open311/endpoint/schema.t b/t/open311/endpoint/schema.t deleted file mode 100644 index b669ca4a5..000000000 --- a/t/open311/endpoint/schema.t +++ /dev/null @@ -1,82 +0,0 @@ -use strict; use warnings; - -use Test::More; -use Test::Exception; - -use Data::Rx; -use Open311::Endpoint; - -my $endpoint = Open311::Endpoint->new; -my $schema = $endpoint->rx; - -subtest 'comma tests' => sub { - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/comma', - }); - } 'Construction dies on no contents'; - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/comma', - contents => '/open311/status', - zirble => 'fleem', - }); - } 'Construction dies on extra arguments'; - - my $comma = $schema->make_schema({ - type => '/open311/comma', - contents => '/open311/status', - trim => 1, - }); - - ok ! $comma->check( undef ), 'Undef is not a valid string'; - ok ! $comma->check( [] ), 'Reference is not a valid string'; - - ok ! $comma->check( 'zibble' ), 'invalid string'; - ok ! $comma->check( 'open,zibble' ), 'an invalid element'; - - ok $comma->check( 'open' ), 'single value'; - ok $comma->check( 'open,closed' ), 'multiple values ok'; - ok $comma->check( 'open, closed ' ), 'spaces trimmed ok'; -}; - -subtest 'datetime tests' => sub { - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/datetime', - zirble => 'fleem', - }); - } 'Construction dies on extra keys'; - - my $dt = $schema->make_schema({ - type => '/open311/datetime', - }); - - ok ! $dt->check( undef ), 'Undef is not a valid string'; - ok ! $dt->check( [] ), 'Reference is not a valid string'; - - ok ! $dt->check( '9th Feb 2012' ), 'invalid datetime format'; - - ok $dt->check( '1994-11-05T08:15:30-05:00' ), 'datetime format with offset'; - ok $dt->check( '1994-11-05T08:15:30+05:00' ), 'datetime format with positive'; - ok $dt->check( '1994-11-05T13:15:30Z' ), 'datetime format zulu'; -}; - -subtest 'identifier tests' => sub { - my $id = $schema->make_schema( '/open311/example/identifier' ); - - ok ! $id->check( undef ), 'Undef is not a valid string'; - ok ! $id->check( '' ), 'Empty string is not a valid identifier'; - ok ! $id->check( 'foo bar' ), 'String with spaces is not a valid identifier'; - - ok $id->check( 'foo' ), 'Ascii word string is a valid identifier'; - ok $id->check( 'foo_bar' ), 'Ascii word string is a valid identifier'; - ok $id->check( 'foo_123' ), 'Ascii word/num string is a valid identifier'; -}; - -done_testing; - -1; diff --git a/t/open311/endpoint/spark.t b/t/open311/endpoint/spark.t deleted file mode 100644 index 015876c94..000000000 --- a/t/open311/endpoint/spark.t +++ /dev/null @@ -1,62 +0,0 @@ -use strict; use warnings; - -use Test::More; - -use Open311::Endpoint; -use Data::Dumper; - -my $endpoint = Open311::Endpoint->new; - -subtest "Spark test" => sub { - my $spark = $endpoint->spark; - my $struct = { - foo => { - service_requests => [ 1,2,3 ], - quxes => [ - { - values => [1,2], - }, - { - values => [3,4], - }, - ], - }, - }; - is_deeply $spark->process_for_json($struct), - { - service_requests => [ 1,2,3 ], - quxes => [ - { - values => [1,2], - }, - { - values => [3,4], - }, - ], - }; - - my $xml_struct = $spark->process_for_xml($struct); - is_deeply $xml_struct, - { - foo => { - service_requests => { request => [ 1,2,3 ] }, - quxes => { - quxe => [ - { - values => { - value => [1,2], - }, - }, - { - values => { - value => [3,4], - }, - }, - ] - }, - } - } - or warn Dumper($xml_struct); -}; - -done_testing; diff --git a/t/open311/endpoint/warwick.t b/t/open311/endpoint/warwick.t deleted file mode 100644 index e5f124c8d..000000000 --- a/t/open311/endpoint/warwick.t +++ /dev/null @@ -1,443 +0,0 @@ -use strict; use warnings; - -use Test::More; -use Test::LongString; -use Test::MockTime ':all'; - -use Data::Dumper; -use JSON::MaybeXS; - -use FixMyStreet::DB; - -use Module::Loaded; -BEGIN { mark_as_loaded('DBD::Oracle') } - -use t::open311::endpoint::Endpoint_Warwick; - -use LWP::Protocol::PSGI; -use Open311::PopulateServiceList; -use Open311::GetServiceRequestUpdates; - -my $endpoint = t::open311::endpoint::Endpoint_Warwick->new; - -subtest "GET Service List" => sub { - my $res = $endpoint->run_test_request( GET => '/services.xml' ); - ok $res->is_success, 'xml success'; - my $expected = <<XML; -<?xml version="1.0" encoding="utf-8"?> -<services> - <service> - <description>Pothole</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>PO</service_code> - <service_name>Pothole</service_name> - <type>realtime</type> - </service> -</services> -XML - is $res->content, $expected - or diag $res->content; -}; - -subtest "POST OK" => sub { - set_fixed_time('2014-01-01T12:00:00Z'); - my $res = $endpoint->run_test_request( - POST => '/requests.json', - api_key => 'test', - service_code => 'PO', - address_string => '22 Acacia Avenue', - first_name => 'Bob', - last_name => 'Mould', - 'attribute[easting]' => 100, - 'attribute[northing]' => 100, - 'attribute[external_id]' => 1001, - 'attribute[closest_address]' => '22 Acacia Avenue', - ); - ok $res->is_success, 'valid request' - or diag $res->content; - - is_deeply decode_json($res->content), - [ { - "service_notice" => "Warwickshire Open311 Endpoint", - "service_request_id" => 1001 - } ], 'correct json returned'; - - is_deeply \%t::open311::endpoint::Endpoint_Warwick::BINDINGS, - { - ':ce_surname' => 'MOULD', - ':ce_y' => '100', - ':ce_x' => '100', - ':ce_work_phone' => '', - ':ce_contact_type' => 'PU', - ':ce_source' => 'FMS', - ':ce_doc_reference' => '1001', - ':ce_enquiry_type' => 'PO', - ':ce_email' => '', - ':ce_description' => '', - ':ce_location' => '22 Acacia Avenue', - ':ce_incident_datetime' => '2014-01-01 12:00', - ':ce_class' => 'N/A', - ':ce_cpr_id' => 5, - ':ce_compl_user_type' => 'USER', - ':ce_status_code' => 'RE', - ':ce_cat' => 'DEF', - ':ce_forename' => 'BOB' - }, - 'bindings as expected'; -}; - -subtest 'updates' => sub { - my $res = $endpoint->run_test_request( GET => '/servicerequestupdates.xml', ); - ok $res->is_success, 'valid request' or diag $res->content; - -my $expected = <<XML; -<?xml version="1.0" encoding="utf-8"?> -<service_request_updates> - <request_update> - <description>Closed the ticket</description> - <media_url></media_url> - <service_request_id>1001</service_request_id> - <status>closed</status> - <update_id>999</update_id> - <updated_datetime>2014-07-23T11:07:00+01:00</updated_datetime> - </request_update> -</service_request_updates> -XML - - is_string $res->content, $expected, 'xml string ok' - or diag $res->content; - - chomp (my $expected_sql = <<SQL); -SELECT * FROM ( - SELECT - row_id, - service_request_id, - to_char(updated_timedate, 'YYYY-MM-DD HH24:MI'), - status, - description - FROM higatlas.fms_update - WHERE updated_timedate >= to_date(2013-12-31 12:00, YYYY-MM-DD HH24:MI) AND (status='OPEN' OR status='CLOSED') - ORDER BY updated_timedate DESC) WHERE ROWNUM <= 1000 -SQL - - is_string $t::open311::endpoint::Endpoint_Warwick::UPDATES_SQL, $expected_sql, 'SQL as expected'; -}; - -subtest "End to end" => sub { - - # We create and instance of the endpoint as a PSGI app - # And then bind it to the dummy URL. This mocks that whole hostname, so that FMS's - # calls via Open311.pm are rerouted to our PSGI app. - # (This saves us all the faff of having to launch and manage a new server process - # for this test) - - my $endpoint_psgi = t::open311::endpoint::Endpoint_Warwick->run_if_script; - - my $ENDPOINT = 'open311.warwickshire.gov.uk'; - LWP::Protocol::PSGI->register($endpoint_psgi, host => $ENDPOINT); - - my $WARWICKSHIRE_MAPIT_ID = 2243; - - my $db = FixMyStreet::DB->connect; - - $db->txn_begin; - - my $body = FixMyStreet::DB->resultset('Body')->find_or_create( { - id => $WARWICKSHIRE_MAPIT_ID, - name => 'Warwickshire County Council', - }); - - my $user = FixMyStreet::DB->resultset('User') - ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); - - $body->update({ - jurisdiction => 'wcc', - endpoint => "http://$ENDPOINT", - api_key => 'SEEKRIT', - send_method => 'Open311', - send_comments => 1, - comment_user_id => $user->id, - }); - - $body->body_areas->find_or_create({ - area_id => $WARWICKSHIRE_MAPIT_ID - } ); - - subtest "Populate service list" => sub { - # as per bin/open311-populate-service-list - - $body->contacts->delete; - - is $body->contacts->count, 0, 'sanity check'; - - my $bodies = self_rs($body); - - my $p = Open311::PopulateServiceList->new( bodies => $bodies, verbose => 0, schema => $db ); - $p->process_bodies; - - is $body->contacts->count, 1, 'Categories imported from Open311'; - }; - - set_fixed_time('2014-07-20T15:05:00Z'); - - my $problem = FixMyStreet::DB->resultset('Problem')->create({ - postcode => 'WC1 1AA', - bodies_str => $WARWICKSHIRE_MAPIT_ID, - areas => ",$WARWICKSHIRE_MAPIT_ID,", - category => 'Pothole', - title => 'Testing', - detail => 'Testing Detail', - used_map => 1, - name => 'Joe Bloggs', - anonymous => 0, - state => 'confirmed', - confirmed => '2014-07-20 15:00:00', - lastupdate => '2014-07-20 15:00:00', - lang => 'en-gb', - service => '', - cobrand => 'fixmystreet', # e.g. UK - cobrand_data => '', - send_questionnaire => 0, - latitude => '52.2804', - longitude => '-1.5897', - user_id => $user->id, - }); - - subtest "Send report" => sub { - # as per bin/send-reports - - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'fixmystreet' ], - SEND_REPORTS_ON_STAGING => 1, - MAPIT_URL => 'http://mapit.mysociety.org/', - }, sub { - ## we can't (yet) just do following due to - ## https://github.com/mysociety/fixmystreet/issues/893 - # self_rs($problem)->send_reports; - - ## instead, as we are in a transaction, we'll just delete everything else. - my $rs = FixMyStreet::DB->resultset('Problem'); - $rs->search({ id => { '!=', $problem->id } })->delete; - $rs->send_reports; - }; - $problem->discard_changes; - - # Our test endpoint returns a hardcoded external ID. - ok $problem->whensent, 'whensent has been set'; - is $problem->external_id, 1001, 'External ID set correctly' - or die; - }; - - subtest "Send update" => sub { - # as per bin/send-reports - - $problem->update({ lastupdate => '2014-07-20 15:05:00' }); # override - - set_fixed_time('2014-07-23T11:07:00Z'); - - is $problem->comments->count, 0, 'sanity check update count'; - is $problem->state, 'confirmed', 'sanity check status'; - - - my $updates = Open311::GetServiceRequestUpdates->new( verbose => 1, schema => $db ); - $updates->fetch; - - $problem->discard_changes; - is $problem->comments->count, 1, 'comment has been added'; - - - my $update = $problem->comments->single; - is $update->user_id, $user->id, 'update user correct'; - is $update->state, 'confirmed', 'update itself is confirmed'; - - is $update->problem_state, 'fixed - council', 'update marked problem as closed'; - is $problem->state, 'fixed - council', 'has been closed'; - }; - - $db->txn_rollback; -}; - -restore_time(); -done_testing; - -sub self_rs { - my ($row) = @_; - # create a result-set with just this body (see also DBIx::Class::Helper::Row::SelfResultSet) - return $row->result_source->resultset->search( $row->ident_condition ); -} - -__END__ - <service> - <description>Bridges</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>BR</service_code> - <service_name>Bridges</service_name> - <type>realtime</type> - </service> - <service> - <description>Carriageway Defect</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>CD</service_code> - <service_name>Carriageway Defect</service_name> - <type>realtime</type> - </service> - <service> - <description>Roads/Highways</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>CD</service_code> - <service_name>Roads/Highways</service_name> - <type>realtime</type> - </service> - <service> - <description>Drainage</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>DR</service_code> - <service_name>Drainage</service_name> - <type>realtime</type> - </service> - <service> - <description>Debris/Spillage</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>DS</service_code> - <service_name>Debris/Spillage</service_name> - <type>realtime</type> - </service> - <service> - <description>Fences</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>FE</service_code> - <service_name>Fences</service_name> - <type>realtime</type> - </service> - <service> - <description>Pavements</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>F D</service_code> - <service_name>Pavements</service_name> - <type>realtime</type> - </service> - <service> - <description>Gully & Catchpits</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>GC</service_code> - <service_name>Gully & Catchpits</service_name> - <type>realtime</type> - </service> - <service> - <description>Ice/Snow</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>IS</service_code> - <service_name>Ice/Snow</service_name> - <type>realtime</type> - </service> - <service> - <description>Mud & Debris</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>MD</service_code> - <service_name>Mud & Debris</service_name> - <type>realtime</type> - </service> - <service> - <description>Manhole</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>MH</service_code> - <service_name>Manhole</service_name> - <type>realtime</type> - </service> - <service> - <description>Oil Spillage</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>OS</service_code> - <service_name>Oil Spillage</service_name> - <type>realtime</type> - </service> - <service> - <description>Other</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>OT</service_code> - <service_name>Other</service_name> - <type>realtime</type> - </service> - - <service> - <description>Property Damage</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>PD</service_code> - <service_name>Property Damage</service_name> - <type>realtime</type> - </service> - <service> - <description>Road Marking</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>RM</service_code> - <service_name>Road Marking</service_name> - <type>realtime</type> - </service> - <service> - <description>Road traffic signs</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>SN</service_code> - <service_name>Road traffic signs</service_name> - <type>realtime</type> - </service> - <service> - <description>Traffic</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>SP</service_code> - <service_name>Traffic</service_name> - <type>realtime</type> - </service> - <service> - <description>Utilities</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>UT</service_code> - <service_name>Utilities</service_name> - <type>realtime</type> - </service> - <service> - <description>Vegetation</description> - <group>highways</group> - <keywords></keywords> - <metadata>true</metadata> - <service_code>VG</service_code> - <service_name>Vegetation</service_name> - <type>realtime</type> - </service> diff --git a/t/open311/endpoint/warwick_dbd.t b/t/open311/endpoint/warwick_dbd.t deleted file mode 100644 index 9120c6467..000000000 --- a/t/open311/endpoint/warwick_dbd.t +++ /dev/null @@ -1,17 +0,0 @@ -use strict; use warnings; - -=head1 NAME - -warwick_dbd.t - test that Oracle constants can be imported if present - -=cut - -use Test::More; - -use lib 't/open311/endpoint/exor/'; - -use DBD::Oracle; # fake from above test lib (or real if installed) -use t::open311::endpoint::Endpoint_Warwick; - -ok 1; -done_testing; |