From a6f76d89efaa561a587290c8a6339fd0b9ebf63d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 6 Jun 2010 17:05:00 +0200 Subject: Detect efa.vrr.de error messages --- bin/efa | 19 ++ test/50-efa.t | 10 +- test/dump_no_connections | 855 ++++++++++++++++++++++++++++++++++++++++++++++ test/parse_no_connections | 6 + 4 files changed, 889 insertions(+), 1 deletion(-) create mode 100644 test/dump_no_connections create mode 100644 test/parse_no_connections diff --git a/bin/efa b/bin/efa index 0670083..4a7f6eb 100755 --- a/bin/efa +++ b/bin/efa @@ -50,6 +50,24 @@ sub check_ambiguous { } } +sub check_no_connections { + my ($full_tree) = @_; + + my $xp_err_img = XML::LibXML::XPathExpression->new( + '//td/img[@src="images/ausrufezeichen.jpg"]'); + + my $err_node = $full_tree->findnodes($xp_err_img)->[0]; + + if ($err_node) { + say "Looks like efa.vrr.de showed an error."; + say "I will now try to dump the error message:"; + + say $err_node->parentNode()->parentNode()->textContent(); + + exit 2; + } +} + sub display_connection { my ($con_parts) = @_; @@ -340,6 +358,7 @@ if ($test_dump) { my $tree = XML::LibXML->load_html(string => $content); check_ambiguous($tree); +check_no_connections($tree); $connections = parse_tree($tree); diff --git a/test/50-efa.t b/test/50-efa.t index 1425696..067b70b 100644 --- a/test/50-efa.t +++ b/test/50-efa.t @@ -3,7 +3,7 @@ use strict; use warnings; use 5.010; -use Test::Command tests => 79; +use Test::Command tests => 82; my $efa = 'bin/efa'; my $testarg = "E HBf MH HBf"; @@ -144,3 +144,11 @@ $cmd = Test::Command->new( $cmd->exit_is_num(1); $cmd->stdout_is_file('test/parse_ambiguous'); $cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new( + cmd => "$efa $test_parse < test/dump_no_connections" +); + +$cmd->exit_is_num(2); +$cmd->stdout_is_file('test/parse_no_connections'); +$cmd->stderr_is_eq($EMPTY); diff --git a/test/dump_no_connections b/test/dump_no_connections new file mode 100644 index 0000000..bc6c481 --- /dev/null +++ b/test/dump_no_connections @@ -0,0 +1,855 @@ + + + +Fahrplanauskunft + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Aushangfahrplan
Abfahrtsmonitor
Persönlicher Fahrplan
Verbundfahrplan Schnellverkehr
Linienplan Schnellverkehr
Stadtlinienpläne
Bedienungshinweise
Bildschirmschoner
Aktuelle Hinweise
Ihr Link zu uns
Impressum
Homepage
+
  + + + + + + + +
+
Fahrplanauskunft
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
*
* + + + + + + +
*Leider konnte für Ihre Anfrage keine Verbindung gefunden werden! Bitte ändern Sie Ihre Eingabe (z.B. Fußwegezeit in den Mobilitätseinstellungen) oder starten Sie eine neue Anfrage!*
+
*
*
*
+ + + + + + + + + + + + +
*
* + + + + + + +
*Leider konnte für Ihre Anfrage keine Verbindung gefunden werden! Bitte ändern Sie Ihre Eingabe (z.B. Fußwegezeit in den Mobilitätseinstellungen) oder starten Sie eine neue Anfrage!*
+
*
*
*
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
*
* von:Stadt/Ort*Zürich*
 
*
*Haltestelle*Hauptbahnhof
**
+
+ + + + + +
+ +
+
+
*
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
*
* nach:Stadt/Ort*Essen*
 
*
*Haltestelle*Hauptbahnhof
**
+
+ + + + + +
+ +
+
+
*
+
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
*
* Linienauswahl
*
*alle Linien
*alle Linien ohne ICE
*nur Verbund-/Nahverkehrslinien
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
*
* Umsteigen / Fußwege
**
zeitkürzeste Verbindungen
Verbindungen mit wenig Umsteigen
Verbindungen mit kurzen Fußwegen
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
*
 Gehgeschwindigkeit 
**
normal
schnell
langsam
+
*
+ + + + + +
 Berücksichtigung von Nachbarhaltestellen bei Start und Ziel
+
*
+
*
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*
* Zeit:
* Abfahrt*Uhr*Datum
* Ankunft     + + + + + + +
*
+
*
+ + + + + + + + + + + + + + + + +
*
***
*
+
+
+
*
+
+ +
+ +
+ +
+ +
+
+ + + +
**
+
+
+ + diff --git a/test/parse_no_connections b/test/parse_no_connections new file mode 100644 index 0000000..f464ad3 --- /dev/null +++ b/test/parse_no_connections @@ -0,0 +1,6 @@ +Looks like efa.vrr.de showed an error. +I will now try to dump the error message: + +Leider konnte für Ihre Anfrage keine Verbindung gefunden werden! Bitte ändern Sie Ihre Eingabe (z.B. Fußwegezeit in den Mobilitätseinstellungen) oder starten Sie eine neue Anfrage! + + -- cgit v1.2.3