summaryrefslogtreecommitdiff
path: root/t/31-db-journey-daychange.t
blob: bb66cdb01bfb5c9df1fefbabebd65f2b19d93efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env perl
use strict;
use warnings;
use 5.020;

use utf8;

use File::Slurp qw(read_file);
use JSON;
use Test::More tests => 36;

use Travel::Status::DE::HAFAS;

my $json = JSON->new->utf8->decode( read_file('t/in/DB.ICE615.journey.json') );

my $status = Travel::Status::DE::HAFAS->new(
	service => 'DB',
	journey => { id => '1|160139|0|81|17122023' },
	json    => $json
);

is( $status->errcode, undef, 'no error code' );
is( $status->errstr,  undef, 'no error string' );

is(
	$status->get_active_service->{name},
	'Deutsche Bahn',
	'active service name'
);

my $result = $status->result;

isa_ok( $result, 'Travel::Status::DE::HAFAS::Journey' );

is( $result->name,      'ICE 615',                'name' );
is( $result->type,      'ICE',                    'type' );
is( $result->type_long, 'Intercity-Express',      'type_long', );
is( $result->class,     1,                        'class' );
is( $result->line,      'ICE 615',                'line' );
is( $result->line_no,   42,                       'line_no' );
is( $result->id,        '1|160139|0|81|17122023', 'id' );
is( $result->operator,  'DB Fernverkehr AG',      'operator' );
is( $result->direction, 'München Hbf',            'direction' );

is( scalar $result->route, 19, 'route == 19' );

is( ( $result->route )[0]->loc->name, 'Hamburg-Altona', 'route[0] name' );
is( ( $result->route )[0]->direction, 'München Hbf',    'route[0] direction' );

is( ( $result->route )[4]->loc->name, 'Bremen Hbf', 'route[4] name' );
is(
	( $result->route )[4]->direction,
	'Frankfurt(M) Flughafen Fernbf',
	'route[4] direction'
);

is( ( $result->route )[5]->loc->name, 'Osnabrück Hbf', 'route[5] name' );
is( ( $result->route )[5]->direction, 'München Hbf',   'route[5] direction' );

is( ( $result->route )[16]->loc->name, 'Augsburg Hbf', 'route[16] name' );
is(
	( $result->route )[16]->arr->strftime('%Y%m%d %H%M%S'),
	'20231217 235300',
	'route[16] arr'
);
is( ( $result->route )[16]->rt_arr, undef, 'route[16] rt_arr' );
is(
	( $result->route )[16]->dep->strftime('%Y%m%d %H%M%S'),
	'20231217 235500',
	'route[16] dep'
);
is( ( $result->route )[16]->rt_dep,    undef, 'route[16] rt_dep' );
is( ( $result->route )[16]->arr_delay, undef, 'route[16] arr_delay' );
is( ( $result->route )[16]->dep_delay, undef, 'route[16] dep_delay' );
is( ( $result->route )[16]->delay,     undef, 'route[16] delay' );

is( ( $result->route )[17]->loc->name, 'München-Pasing', 'route[17] name' );
is(
	( $result->route )[17]->arr->strftime('%Y%m%d %H%M%S'),
	'20231218 001700',
	'route[17] arr'
);
is( ( $result->route )[17]->rt_arr,    undef, 'route[17] rt_arr' );
is( ( $result->route )[17]->dep,       undef, 'route[17] dep' );
is( ( $result->route )[17]->rt_dep,    undef, 'route[17] rt_dep' );
is( ( $result->route )[17]->arr_delay, undef, 'route[17] arr_delay' );
is( ( $result->route )[17]->dep_delay, undef, 'route[17] dep_delay' );
is( ( $result->route )[17]->delay,     undef, 'route[17] delay' );