[0-9\.]{10}).*?09:15<\/td> | (?.*?)<\/td>.*?12:15<\/td> | (?.*?)<\/td>
-attr GeoTest getURL file://geocache-planer.de/CAL/anmeldung.php?date=%%date%%&CALID=XYZ
-attr GeoTest get01Replacement01Value {strftime("%d.%m.%Y", localtime( time))}
-
-attr GeoTest get02Name Test2
-#attr GeoTest get02Replacement01Value {my $NAME = "GeoTest" ;;fhem("deletereading ".$NAME." message");;fhem("deletereading ".$NAME." auth.*");;my @chars=('a'..'z','A'..'Z','0'..'9'); my $r; foreach(1..16) {$r.=$chars[rand @chars];};; fhem("setreading ".$NAME." auth_randomString64 ".$r);; $r;;}
-attr GeoTest get02Replacement01Value {my $NAME = "GeoTest" ;;fhem("deletereading ".$NAME." message");;fhem("deletereading ".$NAME." auth.*");;my @chars=('a'..'z','A'..'Z','0'..'9');; my $r;; foreach(1..16) {$r.=$chars[rand @chars];;};; fhem("setreading ".$NAME." auth_randomString64 ".$r);; $r;;}
-attr GeoTest get02Poll 1
diff --git a/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t b/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t
index 57cd1b07d..c5f48ae5f 100644
--- a/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t
+++ b/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t
@@ -5,14 +5,26 @@
use strict;
use warnings;
use Test::More;
+use FHEM::Modbus::TestUtils qw(:all);
-fhem('set GeoTest reread');
+NextStep();
+sub testStep1 {
+ fhem 'attr H verbose 5';
+ #fhem 'attr H getReplacement01Value {"new"."val"}';
+ fhem 'attr H get01Replacement01Value {"new"."val" err}';
+ #is(FhemTestUtils_gotLog('3 : Invalid Expression'), 1, "found invalid expression");
+ is(FhemTestUtils_gotLog('3\s*:\s*Invalid Expression'), 1, "found invalid expression");
+ fhem 'attr H get01Replacement01Value {"new"."val"}';
+ CheckAndReset();
+ fhem 'attr H get01Data01 header%%date%%';
+ fhem 'get H get01';
+ return 0;
+}
-InternalTimer(time()+1, sub() {
- is(FhemTestUtils_gotLog(qr/Read callback: Error: geocache\-planer.*date=[\d]+\.\d+\.\d+/), 1, "Expr replacement in URL");
- done_testing;
- exit(0);
-}, 0);
+sub testStep2 {
+ LogStep "check results";
+ is(FhemTestUtils_gotLog('data: headernewval'), 1, "did replacement");
+}
1;
diff --git a/fhem/t/FHEM/98_HTTPMOD/90_SmallFeatures.t b/fhem/t/FHEM/98_HTTPMOD/90_SmallFeatures.t
index 0eb34d581..17a963e53 100644
--- a/fhem/t/FHEM/98_HTTPMOD/90_SmallFeatures.t
+++ b/fhem/t/FHEM/98_HTTPMOD/90_SmallFeatures.t
@@ -12,7 +12,7 @@ $modVersion =~ /^([0-9]+)\./;
my $major = $1;
if ($major && $major >= 4) {
- plan tests => 11;
+ plan tests => 13;
} else {
plan skip_all => "This test only works for HTTPMOD version 4 or later, installed is $modVersion";
}
@@ -28,13 +28,17 @@ SKIP: {
is(FhemTestUtils_gotEvent("H2:TestReading1: \x8e\x6e"), 1, "TestReading without bodyDecode");
+CheckAndReset();
+fhem('attr H2 bodyDecode illegal123');
+fhem('attr H2 readingEncode nonsense456');
+is(FhemTestUtils_gotLog("encoding.*is not valid"), 4, "encodings validated");
+
CheckAndReset();
fhem('attr H2 bodyDecode auto');
fhem('attr H2 readingEncode utf8');
fhem('set H2 reread');
is(FhemTestUtils_gotEvent("H2:TestReading1: \xc3\x84\x6e"), 1, "TestReading with body decode");
-
CheckAndReset();
fhem('attr H2 bodyDecode UTF8');
fhem('attr H2 readingEncode utf8');
diff --git a/fhem/t/FHEM/98_HTTPMOD/91_ErrLogLvl.t b/fhem/t/FHEM/98_HTTPMOD/91_ErrLogLvl.t
index 4c87c82d4..8f2336c76 100644
--- a/fhem/t/FHEM/98_HTTPMOD/91_ErrLogLvl.t
+++ b/fhem/t/FHEM/98_HTTPMOD/91_ErrLogLvl.t
@@ -24,8 +24,8 @@ sub testStep1 {
}
sub testStep2 {
- # loginform used fot FhemTestUtils inserts a space between the level and :
- is(FhemTestUtils_gotLog('3 : H1: Read callback: Error'), 1, "standard log level");
+ # loginform used for FhemTestUtils inserts a space between the level and :
+ is(FhemTestUtils_gotLog('3\s*:\s*H1: Read callback: Error'), 1, "standard log level");
FhemTestUtils_resetLogs();
FhemTestUtils_resetEvents();
LogStep "set level go 4";
@@ -35,7 +35,7 @@ sub testStep2 {
}
sub testStep3 {
- is(FhemTestUtils_gotLog('4 : H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "log level 4");
+ is(FhemTestUtils_gotLog('4\s*:\s*H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "log level 4");
FhemTestUtils_resetLogs();
FhemTestUtils_resetEvents();
LogStep "set level regex to timeout only";
@@ -46,7 +46,7 @@ sub testStep3 {
}
sub testStep4 {
- is(FhemTestUtils_gotLog('3 : H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "standard log level because regex doesnt match");
+ is(FhemTestUtils_gotLog('3\s*:\s*H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "standard log level because regex doesnt match");
FhemTestUtils_resetLogs();
FhemTestUtils_resetEvents();
LogStep "set level regex to no such file";
@@ -57,7 +57,7 @@ sub testStep4 {
}
sub testStep5 {
- is(FhemTestUtils_gotLog('4 : H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "log level 4 with match");
+ is(FhemTestUtils_gotLog('4\s*:\s*H1: Read callback: Error: t/FHEM/98_HTTPMOD/NoSuchFile'), 1, "log level 4 with match");
FhemTestUtils_resetLogs();
FhemTestUtils_resetEvents();
return;
diff --git a/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t
index 807c2934f..adbf8562e 100644
--- a/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t
+++ b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t
@@ -37,7 +37,14 @@ is $result, undef, "FormatVal with empty format and undef value";
$format = '%.2f';
$result = FormatVal($hash, {val => $val, format => $format});
-is $result, "0.00", "FormatVal with empty format and undef value";
+is $result, "0.00", "FormatVal with %.2f format and undef value";
+
+# mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1)
+my $time = mktime(0,10,14,1,2,122,0,0,-1); # 1.3.2022 14:10
+$result = FmtDateTimeNice ($time);
+Log3 $name, 1, "result time formatted is $result";
+is $result, "Di 1.Mar 2022 14:10", "FmtDateTimeNice";
+
done_testing;
exit(0);
| |