Add new test case for configurable electricity meters.

pull/465/head
Fredrik Öhrström 2022-02-03 15:40:59 +01:00
rodzic 70b7e51231
commit f04434f505
3 zmienionych plików z 69 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,10 @@
# Test different kinds of electricity meters with radio converters.
# The meters might report the same mfct/media/version but contains
# quite different content.
# This is eBZ DD3 meter with a wMB-E01 wmbus radio converter module.
telegram=|4B445A146450000002378C20F3900F002C25F38B00006CBB07CEB215901172635213015A140102F3002007102F2F#04039D3E03000429E82201000DFD110E333632353331313031305A424531|
{"media":"electricity","meter":"ehzp","name":"MyEl","id":"01135263","total_energy_consumption_kwh":212.637,"current_power_consumption_kw":0.74472,"total_energy_production_kwh":0,"on_time_h":0,"timestamp":"1111-11-11T11:11:11Z"}
|MyEl;01135263;212.637000;0.744720;0.000000;1111-11-11 11:11.11

Wyświetl plik

@ -24,6 +24,9 @@ if [ "$?" != "0" ]; then RC="1"; fi
tests/test_s1_meters.sh $PROG tests/test_s1_meters.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi if [ "$?" != "0" ]; then RC="1"; fi
tests/test_electricity_meters.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_mbus.sh $PROG tests/test_mbus.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi if [ "$?" != "0" ]; then RC="1"; fi

Wyświetl plik

@ -0,0 +1,56 @@
#!/bin/sh
PROG="$1"
mkdir -p testoutput
TEST=testoutput
TESTNAME="Test electricity meters with radio converter plugins"
TESTRESULT="ERROR"
METERS="MyEl ehzp 01135263 NOKEY"
cat simulations/simulation_el_meters.txt | grep '^{' > $TEST/test_expected.txt
$PROG --format=json simulations/simulation_el_meters.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
if [ "$?" = "0" ]
then
echo OK json: $TESTNAME
TESTRESULT="OK"
else
TESTRESULT="ERROR"
fi
else
echo "wmbusmeters returned error code: $?"
cat $TEST/test_output.txt
cat $TEST/test_stderr.txt
fi
cat simulations/simulation_el_meters.txt | grep '^|' | sed 's/^|//' > $TEST/test_expected.txt
$PROG --format=fields simulations/simulation_el_meters.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9].[0-9][0-9]$/1111-11-11 11:11.11/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
if [ "$?" = "0" ]
then
echo OK fields: $TESTNAME
TESTRESULT="OK"
else
TESTRESULT="ERROR"
fi
else
echo "wmbusmeters returned error code: $?"
cat $TEST/test_output.txt
cat $TEST/test_stderr.txt
fi
if [ "$TESTRESULT" = "ERROR" ]
then
echo ERROR: $TESTNAME
exit 1
fi