diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-10-28 14:47:18 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-10-28 14:48:09 +0000 |
commit | b949cd43b196719116a8d6e3dbc2c2598458120b (patch) | |
tree | b3658587a0febfeb9883f6df313e734cb41cadac | |
parent | 179c4ba4e306ec462f190ce15698776a9b2e16d4 (diff) |
Fix some tests not running offline.
-rw-r--r-- | t/app/controller/auth_profile.t | 10 | ||||
-rw-r--r-- | t/cobrand/fixmystreet.t | 4 | ||||
-rw-r--r-- | t/cobrand/isleofwight.t | 12 |
3 files changed, 22 insertions, 4 deletions
diff --git a/t/app/controller/auth_profile.t b/t/app/controller/auth_profile.t index 815098caa..2f0ef6a11 100644 --- a/t/app/controller/auth_profile.t +++ b/t/app/controller/auth_profile.t @@ -1,6 +1,10 @@ +use Test::MockModule; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; +my $resolver = Test::MockModule->new('Email::Valid'); +$resolver->mock('address', sub { $_[1] }); + use t::Mock::Twilio; my $twilio = t::Mock::Twilio->new; @@ -10,10 +14,6 @@ my $test_email = 'test@example.com'; my $test_email2 = 'test@example.net'; my $test_password = 'foobar123'; -END { - done_testing(); -} - # get a sign in email and change password subtest "Test change password page" => sub { $mech->clear_emails_ok; @@ -449,3 +449,5 @@ subtest "Test two-factor authentication admin" => sub { $mech->submit_form_ok({ button => 'toggle_2fa' }, "submit 2FA deactivation"); $mech->content_contains('has been deactivated', "2FA deactivated"); }; + +done_testing(); diff --git a/t/cobrand/fixmystreet.t b/t/cobrand/fixmystreet.t index 6095aee2a..a4d00d032 100644 --- a/t/cobrand/fixmystreet.t +++ b/t/cobrand/fixmystreet.t @@ -1,9 +1,13 @@ use utf8; use FixMyStreet::Script::UpdateAllReports; +use Test::MockModule; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; +my $resolver = Test::MockModule->new('Email::Valid'); +$resolver->mock('address', sub { $_[1] }); + my $body = $mech->create_body_ok( 2514, 'Birmingham' ); my $contact = $mech->create_contact_ok( diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t index fd08ce455..f945dc924 100644 --- a/t/cobrand/isleofwight.t +++ b/t/cobrand/isleofwight.t @@ -1,5 +1,6 @@ use CGI::Simple; use DateTime; +use Test::MockModule; use FixMyStreet::TestMech; use Open311; use Open311::GetServiceRequests; @@ -8,6 +9,16 @@ use Open311::PostServiceRequestUpdates; use FixMyStreet::Script::Alerts; use FixMyStreet::Script::Reports; +# disable info logs for this test run +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + +my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::IsleOfWight'); +$cobrand->mock('lookup_site_code', sub { + my ($self, $row) = @_; + return "Road ID" if $row->latitude == 50.7108; +}); + ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); my $params = { @@ -290,6 +301,7 @@ subtest 'Check special Open311 request handling', sub { my $req = $test_data->{test_req_used}; my $c = CGI::Simple->new($req->content); is $c->param('attribute[urgent]'), undef, 'no urgent param sent'; + is $c->param('attribute[site_code]'), 'Road ID', 'road ID set'; $mech->email_count_is(1); my $email = $mech->get_email; |