Calculated formula now uses the specified unit! Prepare more tests.

pull/708/head
Fredrik Öhrström 2022-11-20 16:38:31 +01:00
rodzic 85a4857124
commit d831d9cc87
8 zmienionych plików z 44 dodań i 33 usunięć

Wyświetl plik

@ -827,7 +827,8 @@ void MeterCommonImplementation::addExtraCalculatedField(string ecf)
"Calculated: "+ecf,
PrintProperty::JSON | PrintProperty::FIELD,
quantity,
parts[1]
parts[1],
unit
);
}

Wyświetl plik

@ -84,8 +84,8 @@ if [ "$?" != "0" ]; then RC="1"; fi
tests/test_multiple_ids.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_conversions.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
#tests/test_conversions.sh $PROG
#if [ "$?" != "0" ]; then RC="1"; fi
tests/test_formulas.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi

Wyświetl plik

@ -7,13 +7,13 @@ mkdir -p $TEST
TESTNAME="Test normal config files with C1 meters"
TESTRESULT="ERROR"
cat simulations/simulation_c1.txt | grep '^{' > $TEST/test_expected.txt
cat simulations/simulation_c1.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt
$PROG --useconfig=tests/config1 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
$PROG --useconfig=tests/config1 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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

Wyświetl plik

@ -1,5 +1,9 @@
#!/bin/sh
# Adding automatic conversions is deprecated!
exit 1
PROG="$1"
rm -rf testoutput

Wyświetl plik

@ -8,7 +8,7 @@ TESTNAME="Test single meter conf file matches any id"
TESTRESULT="ERROR"
rm -f $TEST/meter_readings3/*
cat simulations/simulation_multiple_qcalorics.txt | grep '^{' > $TEST/test_expected.txt
cat simulations/simulation_multiple_qcalorics.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt
$PROG --useconfig=tests/config3 > $TEST/test_output.txt
@ -20,7 +20,7 @@ then
echo Failure, not the expected files in meter readings directory.
exit 1
fi
cat $TEST/meter_readings3/* | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
cat $TEST/meter_readings3/* | jq --sort-keys . | 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

Wyświetl plik

@ -12,22 +12,28 @@ TESTRESULT="ERROR"
$PROG --format=json \
--calculate_sumtemp_c='external_temperature_c+flow_temperature_c' \
--calculate_addtemp_c='external_temperature_c + 1100 c' \
--calculate_external_temperature_f='external_temperature_c' \
23442D2C998734761B168D2087D19EAD217F1779EDA86AB6_710008190000081900007F13 \
MyTapWater multical21 76348799 "" \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
cat > $TEST/test_expected.txt <<EOF
{"media":"cold water","meter":"multical21","name":"MyTapWater","id":"76348799","status":"DRY","total_m3":6.408,"target_m3":6.408,"flow_temperature_c":127,"external_temperature_c":19,"current_status":"DRY","time_dry":"22-31 days","time_reversed":"","time_leaking":"","time_bursting":"","sumtemp_c":146,"addtemp_c":1119,"timestamp":"1111-11-11T11:11:11Z"}
cat <<EOF | jq --sort-keys . > $TEST/test_expected.txt
{"media":"cold water","meter":"multical21","name":"MyTapWater","id":"76348799","status":"DRY","total_m3":6.408,"target_m3":6.408,"flow_temperature_c":127,"external_temperature_c":19,"current_status":"DRY","time_dry":"22-31 days","time_reversed":"","time_leaking":"","time_bursting":"","sumtemp_c":146,"addtemp_c":1119,"external_temperature_f":66.2,"timestamp":"1111-11-11T11:11:11Z"}
EOF
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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: $TESTNAME"
TESTRESULT="OK"
else
if [ "$USE_MELD" = "true" ]
then
meld $TEST/test_expected.txt $TEST/test_responses.txt
fi
fi
fi

Wyświetl plik

@ -21,8 +21,8 @@ then
exit 1
fi
cat simulations/simulation_t1.txt | grep '^{' | grep 12345699 | tail -n 1 > $TEST/test_expected.txt
cat $TEST/meter_readings2/MoreWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
cat simulations/simulation_t1.txt | grep '^{' | grep 12345699 | tail -n 1 | jq --sort-keys . > $TEST/test_expected.txt
cat $TEST/meter_readings2/MoreWater | jq --sort-keys . | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ ! "$?" = "0" ]
then
@ -31,8 +31,8 @@ then
exit 1
fi
cat simulations/simulation_t1.txt | grep '^{' | grep supercom | grep 12345678 | tail -n 1 > $TEST/test_expected.txt
cat $TEST/meter_readings2/MyWarmWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
cat simulations/simulation_t1.txt | grep '^{' | grep supercom | grep 12345678 | tail -n 1 | jq --sort-keys . > $TEST/test_expected.txt
cat $TEST/meter_readings2/MyWarmWater | jq --sort-keys . | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ ! "$?" = "0" ]
then
@ -41,8 +41,8 @@ then
exit 1
fi
cat simulations/simulation_t1.txt | grep '^{' | grep 11111111 | tail -n 1 > $TEST/test_expected.txt
cat $TEST/meter_readings2/MyColdWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
cat simulations/simulation_t1.txt | grep '^{' | grep 11111111 | tail -n 1 | jq --sort-keys . > $TEST/test_expected.txt
cat $TEST/meter_readings2/MyColdWater | jq --sort-keys . | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ ! "$?" = "0" ]
then

Wyświetl plik

@ -10,14 +10,14 @@ TESTRESULT="ERROR"
SIM=simulations/simulation_multiple_qcalorics.txt
cat $SIM | grep '^{' > $TEST/test_expected.txt
cat $SIM | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json $SIM \
Element qcaloric '*' '' \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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
@ -31,16 +31,16 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test listen to wildcard suffix 8856* id"
TESTRESULT="ERROR"
cat $SIM | grep '^{' | grep 8856 > $TEST/test_expected.txt
cat $SIM | grep '^{' | grep 8856 | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json $SIM \
Element qcaloric '8856*' '' \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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
@ -54,15 +54,15 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test listen to two comma separted ids"
TESTRESULT="ERROR"
cat $SIM | grep '^{' | grep -v 88563414 > $TEST/test_expected.txt
cat $SIM | grep '^{' | grep -v 88563414 | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json $SIM \
Element qcaloric '78563412,78563413' '' \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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
@ -76,15 +76,15 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test listen to three comma separted ids"
TESTRESULT="ERROR"
cat $SIM | grep '^{' > $TEST/test_expected.txt
cat $SIM | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json $SIM \
Element qcaloric '78563412,78563413,88563414' '' \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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
@ -98,15 +98,15 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test listen with negated ids"
TESTRESULT="ERROR"
cat $SIM | grep '^{' | grep -v 88563414 | grep -v 78563413 > $TEST/test_expected.txt
cat $SIM | grep '^{' | grep -v 88563414 | grep -v 78563413 | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json $SIM \
Element qcaloric '*,!88563414,!78563413' '' \
> $TEST/test_output.txt
| jq --sort-keys . > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
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