aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Malléjac <clementmallejac@gmail.com>2018-07-27 17:05:53 +0200
committerClément Malléjac <clementmallejac@gmail.com>2018-07-31 17:32:09 +0200
commit349d1c38bfb1ca10ff7391800a1e9c395a2a6cde (patch)
tree574c70ab64b984331f3112ec24094209b871c7f9
parentb5c8b62d0cdb2be9783ed0e77aced499a833e079 (diff)
Setup the project for afb-test frameworksandbox/Excale/testwriting
Wrote a couple of basic API tests Change-Id: I606752e7b46cb2afdc10f3319a24ef15675faa3b Signed-off-by: Clément Malléjac <clementmallejac@gmail.com>
-rw-r--r--test/afb-test/fixtures/sig_test.json30
-rw-r--r--test/afb-test/tests/signal-composer_BasicAPITest.lua43
2 files changed, 63 insertions, 10 deletions
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