Commit a6f76d89 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Detect efa.vrr.de error messages

parent 35577e19
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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);

+9 −1
Original line number Diff line number Diff line
@@ -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);
+855 −0

File added.

Preview size limit exceeded, changes collapsed.

+6 −0
Original line number Diff line number Diff line
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!