def test_0110_send_code_standard(self): """ check if the xpl messages about get_switch_state are OK Sample message : xpl-trig { hop=1 source=domogik-daikcode.domogik-vm1 target=* } irtrans.basic { device=/home device=Daikin remote 1 current=19465224 } dmg_send xpl-cmnd irtrans.basic "device=IRTrans_1,command=send,datatype=IRTrans standard,code=a22222,timing=a45454" """ global device_id global xpl_plugin # do the test print(u"********** start testing xpl command send standard code IR.") command = TestCommand(self, device_id, 'send_standard') print(u'try to send xpl_cmnd fake....' ) # "command" : "send", "datatype" : "IRTrans standard", self.assertTrue( command.test_XplCmd({ "code": CODE_IR, "timing": TIMING }, {"result": "ok"})) msg1_time = datetime.now() time.sleep(8)
def test_0110_send_test_battery(self): """ check if the xpl messages about get_switch_state are OK Sample message : xpl-trig { hop=1 source=domogik-daikcode.domogik-vm1 target=* } irtrans.basic { device=/home device=Daikin remote 1 current=19465224 } dmg_send xpl-cmnd irtrans.basic "device=IRTrans_1,command=send,datatype=IRTrans standard,code=a22222,timing=a45454" """ global device_id global xpl_plugin # do the test print(u"********** start testing xpl command send test_battery_start.") command = TestCommand(self, device_id, 'test_battery_start') print (u'try to send xpl_cmnd fake....') self.assertTrue(command.test_XplCmd({"test": 'a battery test', "command": 'test-battery-start'}, {"result" :"ok"})) msg1_time = datetime.now() time.sleep(8)
def test_0110_get_switch_state(self): """ check if the xpl messages about get_switch_state are OK Sample message : xpl-trig { hop=1 source=domogik-daikcode.domogik-vm1 target=* } sensor.basic { device=/home device=Daikin remote 1 current=19465224 } """ global device_id global xpl_plugin # do the test print(u"********** start testing xpl command set_power.") command = TestCommand(self, device_id, 'set_power') print (u'try to send xpl_cmnd fake....') self.assertTrue(command.test_XplCmd({"command" : "switch", "power" : "On"}, {"state" :"On"})) msg1_time = datetime.now() time.sleep(8) print(u"********** start testing xpl command set_setpoint.") command2 = TestCommand(self, device_id, 'set_setpoint') self.assertTrue(command2.test_XplCmd({"command" : "setpoint", "temp": 23}, {"temp" : 23})) time.sleep(8)
def test_0100_script(self): """ check if after a command is requested over rest, we receive the xpl-trig message and status is stored in database """ global devices command = "/var/lib/domogik/domogik_packages/plugin_script/tests/sample_action.sh" # test print(u"Command = {0}".format(command)) print(u"Device id = {0}".format(devices[command])) # trigger command print(u"Call REST to send an '{0}' command".format(1)) tc = TestCommand(device_id, "cmd_script_action") # send command #tc.send_command(1) # 1 is high tc.send_command({'status' : 1}) # 1 is high print(u"Check that a message with command = 'high' is sent.") self.assertTrue(self.wait_for_xpl(xpltype = "xpl-trig", xplschema = "exec.basic", xplsource = "domogik-{0}.{1}".format(self.name, get_sanitized_hostname()), data = {"type" : "script_action", "command" : command, "status" : "executed"}, timeout = 60)) print(u"Check that the value of the xPL message has been inserted in database") sensor = TestSensor(device_id, "sensor_script_action") print(sensor.get_last_value()) from domogik_packages.plugin_script.conversion.from_executed_to_DT_Trigger import from_executed_to_DT_Trigger # the data is converted to be inserted in database self.assertTrue(int(sensor.get_last_value()[1]) == from_executed_to_DT_Trigger(self.xpl_data.data['status']))
def test_feature(self, address, unit, device_id, command, rest_command): """ Do the tests @param address : device address @param unit : device unit @param device_id : device id @param command @param rest_command """ # test print(u"Device address = {0}".format(address)) print(u"Device unit = {0}".format(unit)) print(u"Device id = {0}".format(device_id)) print(u"Call REST to send an '{0}' command".format(rest_command)) tc = TestCommand(device_id, "switch_lighting2") # send command tc.send_command(rest_command) print(u"Check that a message with command = 'off' is sent.") self.assertTrue(self.wait_for_xpl(xpltype = "xpl-trig", xplschema = "ac.basic", xplsource = "domogik-{0}.{1}".format(self.name, get_sanitized_hostname()), data = {"command" : command, "address" : address, "unit" : unit}, timeout = 60)) print(u"Check that the value of the xPL message has been inserted in database") sensor = TestSensor(device_id, "switch_lighting2") print(sensor.get_last_value()) from domogik_packages.plugin_rfxcom.conversion.from_off_on_to_DT_Switch import from_off_on_to_DT_Switch # the data is converted to be inserted in database self.assertTrue(int(sensor.get_last_value()[1]) == from_off_on_to_DT_Switch(self.xpl_data.data['command']))
def test_0100_wol(self): """ check if after a command is requested over rest, we receive the xpl-trig message and status is sotred in database """ global devices global wol_port mac = "112233445566" port = 9 # test print(u"Device mac address = {0}".format(mac)) print(u"Device port = {0}".format(port)) print(u"Device id = {0}".format(devices[mac])) print(u"Call REST to send an '{0}' command".format(1)) tc = TestCommand(device_id, "wol") # send command #tc.send_command(1) # 1 is high tc.send_command({'current' : 1}) # 1 is high print(u"Check that a message with command = 'high' is sent.") self.assertTrue(self.wait_for_xpl(xpltype = "xpl-trig", xplschema = "sensor.basic", xplsource = "domogik-{0}.{1}".format(self.name, get_sanitized_hostname()), data = {"device" : mac, "port" : port, "type" : "wakeonlan", "current" : "high"}, timeout = 60)) print(u"Check that the value of the xPL message has been inserted in database") sensor = TestSensor(device_id, "wol") print(sensor.get_last_value()) from domogik_packages.plugin_wol.conversion.from_high_to_DT_Trigger import from_high_to_DT_Trigger # the data is converted to be inserted in database self.assertTrue(int(sensor.get_last_value()[1]) == from_high_to_DT_Trigger(self.xpl_data.data['current']))
def test_0110_get_switch_state(self): """ check if the xpl messages about get_switch_state are OK Sample message : xpl-trig { hop=1 source=domogik-daikcode.domogik-vm1 target=* } sensor.basic { device=/home device=Daikin remote 1 current=19465224 } """ global device_id global xpl_plugin # do the test print(u"********** start testing xpl command set_power.") command = TestCommand(self, device_id, 'set_power') print(u'try to send xpl_cmnd fake....') self.assertTrue( command.test_XplCmd({ "command": "switch", "power": "On" }, {"state": "On"})) msg1_time = datetime.now() time.sleep(8) print(u"********** start testing xpl command set_setpoint.") command2 = TestCommand(self, device_id, 'set_setpoint') self.assertTrue( command2.test_XplCmd({ "command": "setpoint", "temp": 23 }, {"temp": 23})) time.sleep(8)