summaryrefslogtreecommitdiffstats
path: root/test/afb-test/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/afb-test/tests')
-rw-r--r--test/afb-test/tests/signal-composer_BasicAPITest.lua201
1 files changed, 121 insertions, 80 deletions
diff --git a/test/afb-test/tests/signal-composer_BasicAPITest.lua b/test/afb-test/tests/signal-composer_BasicAPITest.lua
index 30c4f3a..fe8a78c 100644
--- a/test/afb-test/tests/signal-composer_BasicAPITest.lua
+++ b/test/afb-test/tests/signal-composer_BasicAPITest.lua
@@ -20,32 +20,57 @@
local testPrefix ="signal_composer_BasicAPITest_";
--- This tests the 'list' verb of the signal-composer API
-_AFT.testVerbStatusSuccess(testPrefix.."list","signal-composer","list", {});
+--[[
+################################################################################
+########################## Subscribe/Unsubscribe ###############################
+################################################################################
+]]
+---------------------------
+-- Successful verb calls --
+---------------------------
-- This tests the 'subscribe' verb of the signal-composer API
-_AFT.testVerbStatusSuccess(testPrefix.."subscribe","signal-composer","subscribe",{ signal = "longitude"},nil,
- function()
- _AFT.callVerb("signal-composer","unsubscribe",{ signal = "longitude"})
- end);
-
+_AFT.testVerbStatusSuccess(testPrefix.."subscribe","signal-composer","subscribe",{ signal = "longitude"}, nil,
+ function()
+ _AFT.callVerb("signal-composer","unsubscribe",{ signal = "longitude"})
+ end);
-- This tests the 'unsubscribe' verb of the signal-composer API
_AFT.testVerbStatusSuccess(testPrefix.."unsubscribe","signal-composer","unsubscribe",{ signal = "heading"},
- function()
- _AFT.callVerb("signal-composer","subscribe",{ signal = "heading"})
- end, nil);
+ function()
+ _AFT.callVerb("signal-composer","subscribe",{ signal = "heading"})
+ end, nil);
-- This tests the 'unsubscribe' verb of the signal-composer API when we are not actually subscribed to a signal
_AFT.testVerbStatusSuccess(testPrefix.."doubleUnsubscribe","signal-composer","unsubscribe",{ signal = "latitude"},
- function()
- _AFT.callVerb("signal-composer","unsubscribe",{ signal = "latitude"})
- end,nil);
+ function()
+ _AFT.callVerb("signal-composer","unsubscribe",{ signal = "latitude"})
+ end, nil);
-- This tests the 'unsubscribe' verb of the signal-composer API when unsubscribing from a non-existing signal
_AFT.testVerbStatusSuccess(testPrefix.."unsubscribeNonExistingSignal","signal-composer","unsubscribe",{ signal = "notASignal"});
+-----------------------
+-- Failed verb calls --
+-----------------------
+
+-- This tests the 'subscribe' verb of the signal-composer API, with a non existing signal, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."subscribeNonExistingSignal","signal-composer","subscribe",{ signal = "notASignal"});
+
+--[[
+################################################################################
+################################ List/Get ######################################
+################################################################################
+]]
+
+---------------------------
+-- Successful verb calls --
+---------------------------
+
+-- This tests the 'list' verb of the signal-composer API
+_AFT.testVerbStatusSuccess(testPrefix.."list","signal-composer","list", {});
+
-- This tests the 'get' verb of the signal-composer API, without any options, this should return the last value for that signal
_AFT.testVerbStatusSuccess(testPrefix.."getNoFilter","signal-composer","get",{signal= "fuel_level"});
@@ -58,23 +83,53 @@ _AFT.testVerbStatusSuccess(testPrefix.."getFilterMin","signal-composer","get",{s
-- This tests the 'get' verb of the signal-composer API, with the 'maximum' option, this should return the maximum value over the last X seconds
_AFT.testVerbStatusSuccess(testPrefix.."getFilterMax","signal-composer","get",{signal= "vehicle_speed", options= {maximum= 10}});
+-- This tests the 'get' verb of the signal-composer API, with the 'last' option, this should return the last value over the last X seconds
+_AFT.testVerbStatusSuccess(testPrefix.."getFilterMax","signal-composer","get",{signal= "fuel_level", options= {last= 10}});
+
+-----------------------
+-- Failed verb calls --
+-----------------------
+
+-- This tests the 'get' verb of the signal-composer API, with an invalid option name, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."getFilterInvalid","signal-composer","get",{signal= "latitude", options= {notValid= 10}});
+
+-- This tests the 'get' verb of the signal-composer API, with a non existing signal, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."getNoFilterInvalidSignal","signal-composer","get",{signal= "notAValidSignal"});
+
+-- This tests the 'get' verb of the signal-composer API, with an invalid option value, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."getFilterOptionInvalidValue","signal-composer","get",{signal= "odometer", options= {average= -1}});
+
+-- This tests the 'get' verb of the signal-composer API, with an invalid parameter name, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."getFilterInvalidFirstArgument","signal-composer","get",{notValidAtAll= "vehicule_speed", options= {average= 10}});
+
+-- This tests the 'get' verb of the signal-composer API, with an invalid second parameter name, it should reply with an error
+_AFT.testVerbStatusError(testPrefix.."getFilterInvalidSecondArgument","signal-composer","get",{signal= "vehicule_speed", notValidAtAll= {average= 10}});
+
+--[[
+################################################################################
+########################### Adding new signals #################################
+################################################################################
+]]
+
+---------------------------
+-- Successful verb calls --
+---------------------------
+
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing signals
then making a get, a subscribe, and an unsubscribe looking for any misbehaviour from signals added with the verb ]]
-_AFT.describe(testPrefix.."addObjectsByFile",function()
- _AFT.assertVerbStatusSuccess("signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_test.json"})
- _AFT.assertVerbStatusSuccess("signal-composer","get",{signal= "vehicle_speedTest1",options= {average=10}});
- _AFT.assertVerbStatusSuccess("signal-composer","subscribe",{ signal = "vehicle_speedTest1"});
- _AFT.assertVerbStatusSuccess("signal-composer","unsubscribe",{ signal = "vehicle_speedTest1"});
-end);
-
-_AFT.setAfter(testPrefix.."addObjectsByFile",function()
- _AFT.callVerb("signal-composer","unsubscribe",{ signal = "vehicle_speedTest1"})
+ _AFT.describe(testPrefix.."addSignalsByFile", function()
+ _AFT.assertVerbStatusSuccess("signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_test.json"})
+ _AFT.assertVerbStatusSuccess("signal-composer","get",{signal= "vehicle_speedTest1", options= {average=10}});
+ _AFT.assertVerbStatusSuccess("signal-composer","subscribe",{ signal = "vehicle_speedTest1"});
+ _AFT.assertVerbStatusSuccess("signal-composer","unsubscribe",{ signal = "vehicle_speedTest1"});
+ end);
+
+_AFT.setAfter(testPrefix.."addSignalsByFile", function()
+ _AFT.callVerb("signal-composer","unsubscribe",{ signal = "vehicle_speedTest1"})
end)
-
-
-- This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table
-_AFT.testVerbStatusSuccess(testPrefix.."addObjectsDirect","signal-composer","addObjects",
+_AFT.testVerbStatusSuccess(testPrefix.."addSignalsDirect","signal-composer","addObjects",
{
signals= {
{
@@ -102,83 +157,69 @@ _AFT.testVerbStatusSuccess(testPrefix.."addObjectsDirect","signal-composer","add
event= "engine_speed"
}
}
- }
+ }
}
);
+-----------------------
+-- Failed verb calls --
+-----------------------
+
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table.
This one has invalid values for most of its field, the binding should not be able to add it ]]
-_AFT.testVerbStatusError(testPrefix.."addObjectsDirect_InvalidSignal","signal-composer","addObjects",
-{
- signals= {
- {
- uid= "invalidSignal",
- event= "txc-binding/invalidSignal",
- retention= -1,
- unit= "invalidSignal",
- getSignalsArgs= {
- event= "invalidSignal"
- },
- onReceived= {
- action= "lua://convert#_Unit_Converter",
- args= {
- from= "km/h",
- to= "mi/h"
+_AFT.testVerbStatusError(testPrefix.."addSignalsDirect_InvalidSignal","signal-composer","addObjects",
+ {
+ signals= {
+ {
+ uid= "invalidSignal",
+ event= "txc-binding/invalidSignal",
+ retention= -1,
+ unit= "invalidSignal",
+ getSignalsArgs= {
+ event= "invalidSignal"
+ },
+ onReceived= {
+ action= "lua://convert#_Unit_Converter",
+ args= {
+ from= "km/h",
+ to= "mi/h"
+ }
}
}
}
- }
-}
+ }
);
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table.
This one is missing the mandatory 'uid' field, the binding should not be able to add it ]]
-_AFT.testVerbStatusError(testPrefix.."addObjectsDirect_MissingField","signal-composer","addObjects",
+_AFT.testVerbStatusError(testPrefix.."addSignalsDirect_MissingField","signal-composer","addObjects",
{
- signals= {
- {
- event= "txc-binding/invalidSignal2",
- retention= 30,
- unit= "km/h",
- getSignalsArgs= {
- event= "vehicle_speed"
- },
- onReceived= {
- action= "lua://convert#_Unit_Converter",
- args= {
- from= "km/h",
- to= "mi/h"
+ signals= {
+ {
+ event= "txc-binding/invalidSignal2",
+ retention= 30,
+ unit= "km/h",
+ getSignalsArgs= {
+ event= "vehicle_speed"
+ },
+ onReceived= {
+ action= "lua://convert#_Unit_Converter",
+ args= {
+ from= "km/h",
+ to= "mi/h"
+ }
}
}
}
- }
-}
+ }
);
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing signals
This one has invalid values for most of its field, the binding should not be able to add it ]]
-_AFT.testVerbStatusError(testPrefix.."addObjectsByFile_InvalidSignal","signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_testInvalid.json"});
+_AFT.testVerbStatusError(testPrefix.."addSignalsByFile_InvalidSignal","signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_testInvalid.json"});
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing signals
This one is missing the mandatory 'uid' field, the binding should not be able to add it ]]
-_AFT.testVerbStatusError(testPrefix.."addObjectsByFile_Missingfield","signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_incomplete.json"});
-
--- This tests the 'subscribe' verb of the signal-composer API, with a non existing signal, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."subscribeNonExistingSignal","signal-composer","subscribe",{ signal = "notASignal"});
-
--- This tests the 'get' verb of the signal-composer API, with an invalid option name, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."getFilterInvalid","signal-composer","get",{signal= "latitude", options= {notValid= 10}});
-
--- This tests the 'get' verb of the signal-composer API, with a non existing signal, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."getNoFilterInvalidSignal","signal-composer","get",{signal= "notAValidSignal"});
-
--- This tests the 'get' verb of the signal-composer API, with an invalid option value, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."getFilterOptionInvalidValue","signal-composer","get",{signal= "odometer", options= {average= -1}});
-
--- This tests the 'get' verb of the signal-composer API, with an invalid parameter name, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."getFilterInvalidFirstArgument","signal-composer","get",{notValidAtAll= "vehicule_speed", options= {average= 10}});
-
--- This tests the 'get' verb of the signal-composer API, with an invalid second parameter name, it should reply with an error
-_AFT.testVerbStatusError(testPrefix.."getFilterInvalidSecondArgument","signal-composer","get",{signal= "vehicule_speed", notValidAtAll= {average= 10}});
+_AFT.testVerbStatusError(testPrefix.."addSignalsByFile_Missingfield","signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_incomplete.json"});
_AFT.exitAtEnd();