Skip to content

Commit

Permalink
add route and route_interesting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
derf committed Dec 16, 2023
1 parent 148e608 commit ea967c1
Showing 1 changed file with 232 additions and 1 deletion.
233 changes: 232 additions & 1 deletion t/20-db.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use utf8;

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

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

Expand Down Expand Up @@ -61,6 +61,86 @@ for my $res ( $results[0]->route_end, $results[0]->destination ) {
is( $res, 'Philharmonie Süd, Berlin', 'result 0: route start/end' );
}

is( scalar $results[0]->route_interesting,
3, 'result 0: route_interesting: 3 elements' );
is(
( $results[0]->route_interesting )[0]->loc->name,
'Alexanderstr., Berlin',
'result 0: route_interesting 0: name'
);
is(
( $results[0]->route_interesting )[1]->loc->name,
'Alexanderplatz (S+U)/Grunerstr., Berlin',
'result 0: route_interesting 1: name'
);
is(
( $results[0]->route_interesting )[2]->loc->name,
'Rotes Rathaus (U), Berlin',
'result 0: route_interesting 2: name'
);

is( scalar $results[0]->route, 12, 'result 0: route: 12 elements' );
is(
( $results[0]->route )[0]->loc->name,
'Alexanderstr., Berlin',
'result 0: route 0: name'
);
is(
( $results[0]->route )[1]->loc->name,
'Alexanderplatz (S+U)/Grunerstr., Berlin',
'result 0: route 1: name'
);
is(
( $results[0]->route )[2]->loc->name,
'Rotes Rathaus (U), Berlin',
'result 0: route 2: name'
);
is(
( $results[0]->route )[3]->loc->name,
'Museumsinsel (U), Berlin',
'result 0: route 3: name'
);
is(
( $results[0]->route )[4]->loc->name,
'Staatsoper, Berlin',
'result 0: route 4: name'
);
is(
( $results[0]->route )[5]->loc->name,
'Unter den Linden (U), Berlin',
'result 0: route 5: name'
);
is(
( $results[0]->route )[6]->loc->name,
'Behrenstr./Wilhelmstr., Berlin',
'result 0: route 6: name'
);
is(
( $results[0]->route )[7]->loc->name,
'Mohrenstr. (U), Berlin',
'result 0: route 7: name'
);
is(
( $results[0]->route )[8]->loc->name,
'Leipziger Str./Wilhelmstr., Berlin',
'result 0: route 8: name'
);
is(
( $results[0]->route )[9]->loc->name,
'Potsdamer Platz [Bus Leipziger Str.] (S+U), Berlin',
'result 0: route 9: name'
);
is(
( $results[0]->route )[10]->loc->name,
'Varian-Fry-Str./Potsdamer Platz, Berlin',
'result 0: route 10: name'
);
is(
( $results[0]->route )[11]->loc->name,
'Philharmonie Süd, Berlin',
'result 0: route 11: name'
);

is(
$results[0]->sched_datetime->strftime('%Y%m%d %H%M%S'),
'20221002 165500',
Expand Down Expand Up @@ -96,6 +176,66 @@ for my $res ( $results[2]->route_end, $results[2]->destination ) {
is( $res, 'Hermannstr. (S+U), Berlin', 'result 2: route start/end' );
}

is( scalar $results[2]->route_interesting,
3, 'result 2: route_interesting: 3 elements' );
is(
( $results[2]->route_interesting )[0]->loc->name,
'Heinrich-Heine-Str. (U), Berlin',
'result 2: route_interesting 0: name'
);
is(
( $results[2]->route_interesting )[1]->loc->name,
'Moritzplatz (U), Berlin',
'result 2: route_interesting 1: name'
);
is(
( $results[2]->route_interesting )[2]->loc->name,
'Kottbusser Tor (U), Berlin',
'result 2: route_interesting 2: name'
);

is( scalar $results[2]->route, 8, 'result 2: route: 8 elements' );
is(
( $results[2]->route )[0]->loc->name,
'Heinrich-Heine-Str. (U), Berlin',
'result 2: route 0: name'
);
is(
( $results[2]->route )[1]->loc->name,
'Moritzplatz (U), Berlin',
'result 2: route 1: name'
);
is(
( $results[2]->route )[2]->loc->name,
'Kottbusser Tor (U), Berlin',
'result 2: route 2: name'
);
is(
( $results[2]->route )[3]->loc->name,
'Schönleinstr. (U), Berlin',
'result 2: route 3: name'
);
is(
( $results[2]->route )[4]->loc->name,
'Hermannplatz (U), Berlin',
'result 2: route 4: name'
);
is(
( $results[2]->route )[5]->loc->name,
'Boddinstr. (U), Berlin',
'result 2: route 5: name'
);
is(
( $results[2]->route )[6]->loc->name,
'Leinestr. (U), Berlin',
'result 2: route 6: name'
);
is(
( $results[2]->route )[7]->loc->name,
'Hermannstr. (S+U), Berlin',
'result 2: route 7: name'
);

is(
$results[2]->sched_datetime->strftime('%Y%m%d %H%M%S'),
'20221002 170000',
Expand Down Expand Up @@ -130,6 +270,97 @@ for my $res ( $results[3]->route_end, $results[3]->destination ) {
is( $res, 'Berlin-Spandau (S)', 'result 3: route start/end' );
}

is( scalar $results[3]->route_interesting,
3, 'result 3: route_interesting: 3 elements' );
is(
( $results[3]->route_interesting )[0]->loc->name,
'Berlin Alexanderplatz (S)',
'result 3: route_interesting 0: name'
);
is(
( $results[3]->route_interesting )[1]->loc->name,
'Berlin Hackescher Markt',
'result 3: route_interesting 1: name'
);
is(
( $results[3]->route_interesting )[2]->loc->name,
'Berlin Hbf (S-Bahn)',
'result 3: route_interesting 2: name'
);

is( scalar $results[3]->route, 16, 'result 3: route: 16 elements' );
is(
( $results[3]->route )[0]->loc->name,
'Berlin Alexanderplatz (S)',
'result 3: route 0: name'
);
is(
( $results[3]->route )[1]->loc->name,
'Berlin Hackescher Markt',
'result 3: route 1: name'
);
is(
( $results[3]->route )[2]->loc->name,
'Berlin Friedrichstraße (S)',
'result 3: route 2: name'
);
is(
( $results[3]->route )[3]->loc->name,
'Berlin Hbf (S-Bahn)',
'result 3: route 3: name'
);
is(
( $results[3]->route )[4]->loc->name,
'Berlin Bellevue',
'result 3: route 4: name'
);
is( ( $results[3]->route )[5]->loc->name,
'Berlin-Tiergarten', 'result 3: route 5: name' );
is(
( $results[3]->route )[6]->loc->name,
'Berlin Zoologischer Garten (S)',
'result 3: route 6: name'
);
is(
( $results[3]->route )[7]->loc->name,
'Berlin Savignyplatz',
'result 3: route 7: name'
);
is(
( $results[3]->route )[8]->loc->name,
'Berlin Charlottenburg (S)',
'result 3: route 8: name'
);
is(
( $results[3]->route )[9]->loc->name,
'Berlin Westkreuz',
'result 3: route 9: name'
);
is(
( $results[3]->route )[10]->loc->name,
'Berlin Messe Süd (Eichkamp)',
'result 3: route 10: name'
);
is(
( $results[3]->route )[11]->loc->name,
'Berlin Heerstraße',
'result 3: route 11: name'
);
is(
( $results[3]->route )[12]->loc->name,
'Berlin Olympiastadion',
'result 3: route 12: name'
);
is( ( $results[3]->route )[13]->loc->name,
'Berlin-Pichelsberg', 'result 3: route 17: name' );
is( ( $results[3]->route )[14]->loc->name,
'Berlin-Stresow', 'result 3: route 14: name' );
is(
( $results[3]->route )[15]->loc->name,
'Berlin-Spandau (S)',
'result 3: route 15: name'
);

is(
$results[3]->sched_datetime->strftime('%Y%m%d %H%M%S'),
'20221002 170100',
Expand Down

0 comments on commit ea967c1

Please sign in to comment.