From 349d1c38bfb1ca10ff7391800a1e9c395a2a6cde Mon Sep 17 00:00:00 2001 From: Clément Malléjac Date: Fri, 27 Jul 2018 17:05:53 +0200 Subject: Setup the project for afb-test framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrote a couple of basic API tests Change-Id: I606752e7b46cb2afdc10f3319a24ef15675faa3b Signed-off-by: Clément Malléjac --- test/afb-test/fixtures/sig_test.json | 30 +++++++++++++++ .../tests/signal-composer_BasicAPITest.lua | 43 +++++++++++++++++----- 2 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 test/afb-test/fixtures/sig_test.json diff --git a/test/afb-test/fixtures/sig_test.json b/test/afb-test/fixtures/sig_test.json new file mode 100644 index 0000000..1325315 --- /dev/null +++ b/test/afb-test/fixtures/sig_test.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://iot.bzh/download/public/schema/json/signal-composer-schema.json", + "signals": [ + { + "uid": "test_signal", + "event": "txc/vehicle_speed", + "retention": 30, + "unit": "km/h", + "getSignalsArgs": { + "event": "vehicle_speed" + }, + "onReceived": { + "action": "lua://convert#_Unit_Converter", + "args": { + "from": "km/h", + "to": "mi/h" + } + } + }, + { + "uid": "engine_speed", + "event": "txc/engine_speed", + "retention": 30, + "unit": "rpm", + "getSignalsArgs": { + "event": "engine_speed" + } + } + ] +} diff --git a/test/afb-test/tests/signal-composer_BasicAPITest.lua b/test/afb-test/tests/signal-composer_BasicAPITest.lua index c1d3855..4c37edf 100644 --- a/test/afb-test/tests/signal-composer_BasicAPITest.lua +++ b/test/afb-test/tests/signal-composer_BasicAPITest.lua @@ -18,20 +18,43 @@ NOTE: strict mode: every global variables should be prefixed by '_' --]] -_AFT.testVerb("signal_composer_BasicAPITest_subscribe","signal-composer","subscribe",{ event = "longitude"},nil, + +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_list","signal-composer","list", {}); + +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_subscribe","signal-composer","subscribe",{ signal = "longitude"},nil, function() - _AFT.callVerb("signal-composer","unsubscribe",{ event = "longitude"}) + _AFT.callVerb("signal-composer","unsubscribe",{ signal = "longitude"}) end); -_AFT.testVerb("signal_composer_BasicAPITest_unsubscribe","signal-composer","unsubscribe",{ event = "heading"},nil, + +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_unsubscribe","signal-composer","unsubscribe",{ signal = "heading"}, function() - _AFT.callVerb("signal-composer","subscribe",{ event = "heading"}) - end); + _AFT.callVerb("signal-composer","subscribe",{ signal = "heading"}) + end, nil); + +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_doubleUnsubscribe","signal-composer","unsubscribe",{ signal = "latitude"}, + function() + _AFT.callVerb("signal-composer","unsubscribe",{ signal = "latitude"}) + end,nil); + +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getNoFilter","signal-composer","get",{signal= "fuel_level"}); +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getFilterAvg","signal-composer","get",{signal= "odometer", options= {average= 10}}); +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getFilterMin","signal-composer","get",{signal= "latitude", options= {minimum= 10}}); +_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getFilterMax","signal-composer","get",{signal= "vehicle_speed", options= {maximum= 10}}); + +-- Adding object +--_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getFilterMax","signal-composer","addObjects",{file = "sig_test.json"}); +--_AFT.testVerbStatusSuccess("signal_composer_BasicAPITest_getFilterMax","signal-composer","addObjects",{}); + +-- + + + -_AFT.testVerb("signal_composer_BasicAPITest_getNoFilter","signal-composer","get",{signal= "fuel_level"}); -_AFT.testVerb("signal_composer_BasicAPITest_getFilterAvg","signal-composer","get",{signal= "odometer", options= {average= 10}}); -_AFT.testVerb("signal_composer_BasicAPITest_getFilterMin","signal-composer","get",{signal= "latitude", options= {minimum= 10}}); -_AFT.testVerb("signal_composer_BasicAPITest_getFilterMax","signal-composer","get",{signal= "vehicle_speed", options= {maximum= 10}}); -_AFT.testVerb("signal_composer_BasicAPITest_list","signal-composer","list"); +_AFT.testVerbStatusError("signal_composer_BasicAPITest_getNoFilterInvalidSignal","signal-composer","get", {signal= "notAValidSignal"}); +_AFT.testVerbStatusError("signal_composer_BasicAPITest_getFilterOptionInvalidValue","signal-composer","get", {signal= "odometer", options= {average= -1}}); +_AFT.testVerbStatusError("signal_composer_BasicAPITest_getFilterInvalid","signal-composer","get", {signal= "latitude", options= {notValid= 10}}); +_AFT.testVerbStatusError("signal_composer_BasicAPITest_getFilterInvalidFirstArgument","signal-composer","get", {notValidAtAll= "vehicule_speed", options= {average= 10}}); +_AFT.testVerbStatusError("signal_composer_BasicAPITest_getFilterInvalidSecondArgument","signal-composer","get", {signal= "vehicule_speed", notValidAtAll= {average= 10}}); _AFT.exitAtEnd(); \ No newline at end of file -- cgit 1.2.3-korg