| 1 | package WWW::AzimuthAero::Mock; | ||
| 2 | 1 | $WWW::AzimuthAero::Mock::VERSION = '0.3'; | |
| 3 | |||
| 4 | # ABSTRACT: additional subroutines for unit testing | ||
| 5 | |||
| 6 | |||
| 7 | 1 | ▶ | use DateTime; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Mojo::UserAgent::Mockable; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use feature 'say'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | |||
| 12 | sub mock_data { | ||
| 13 | return { | ||
| 14 | 0 | ▶ | get => { |
|
Subroutine
mock_data: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 15 | |||
| 16 | # uncomment when check for new DOM and change date next after testing | ||
| 17 | # from => 'ROV', to => 'MOW', date => DateTime->now->add(weeks=>2)->dmy('.') | ||
| 18 | from => 'ROV', | ||
| 19 | to => 'MOW', | ||
| 20 | date => '23.06.2019' | ||
| 21 | } | ||
| 22 | }; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub filename { | ||
| 26 | 0 | ▶ | return 't/ua_mock.json'; |
|
Subroutine
filename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | sub generate { | ||
| 31 | 0 | ▶ | my $self = shift; |
|
Subroutine
generate: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 32 | 0 | my $mock_data = $self->mock_data->{get}; | |
| 33 | |||
| 34 | 0 | my $ua = Mojo::UserAgent::Mockable->new( | |
| 35 | mode => 'record', | ||
| 36 | file => $self->filename, | ||
| 37 | ignore_headers => 1 | ||
| 38 | ); | ||
| 39 | 0 | $ua->get('https://booking.azimuth.aero/'); | |
| 40 | my $url = | ||
| 41 | 'https://booking.azimuth.aero/!/' | ||
| 42 | . $mock_data->{from} . '/' | ||
| 43 | . $mock_data->{to} . '/' | ||
| 44 | . $mock_data->{date} | ||
| 45 | 0 | . '/1-0-0/'; | |
| 46 | 0 | $ua->get($url)->res->dom; | |
| 47 | 0 | $ua->save; | |
| 48 | 0 | say 'please manually check prices at ' . $url | |
| 49 | . ' and fix 01-AzimuthAero.t if needed'; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1 | 1; | |
| 53 | |||
| 54 | __END__ | ||
| 55 | |||
| 56 | =pod | ||
| 57 | |||
| 58 | =encoding UTF-8 | ||
| 59 | |||
| 60 | =head1 NAME | ||
| 61 | |||
| 62 | WWW::AzimuthAero::Mock - additional subroutines for unit testing | ||
| 63 | |||
| 64 | =head1 VERSION | ||
| 65 | |||
| 66 | version 0.3 | ||
| 67 | |||
| 68 | =head1 SYNOPSIS | ||
| 69 | |||
| 70 | perl -Ilib -e "use WWW::AzimuthAero::Mock; WWW::AzimuthAero::Mock->generate()" | ||
| 71 | |||
| 72 | =head1 DESCRIPTION | ||
| 73 | |||
| 74 | Some helpers to generate mocks | ||
| 75 | |||
| 76 | =head2 mock_data | ||
| 77 | |||
| 78 | Return data that is used for mock at unit tests | ||
| 79 | |||
| 80 | =head2 generate | ||
| 81 | |||
| 82 | Generate json mock data | ||
| 83 | |||
| 84 | =head1 AUTHOR | ||
| 85 | |||
| 86 | Pavel Serikov <pavelsr@cpan.org> | ||
| 87 | |||
| 88 | =head1 COPYRIGHT AND LICENSE | ||
| 89 | |||
| 90 | This software is copyright (c) 2019 by Pavel Serikov. | ||
| 91 | |||
| 92 | This is free software; you can redistribute it and/or modify it under | ||
| 93 | the same terms as the Perl 5 programming language system itself. | ||
| 94 | |||
| 95 | =cut | ||