Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
greens committed Aug 2, 2023
1 parent 1d67522 commit 80f168a
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

-- Mock out globals
local test = require "integration_test"
-- local capabilities = require "st.capabilities"
local capabilities = require "st.capabilities"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local t_utils = require "integration_test.utils"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local zcl_commands = require "st.zigbee.zcl.global_commands"
local multi_utils = require "multi-sensor/multi_utils"
local zcl_clusters = require "st.zigbee.zcl.clusters"
local contactSensor_defaults = require "st.zigbee.defaults.contactSensor_defaults"
local capabilities = require "st.capabilities"

local MULTI_SENSOR_FINGERPRINTS = {
{ mfr = "CentraLite", model = "3320" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

local capabilities = require "st.capabilities"

local function added_handler(self, device)
-- Aurora Smart PIR Sensor doesn't report when there is no motion during pairing process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"

local capabilities = require "st.capabilities"
local OnOff = clusters.OnOff
local Level = clusters.Level

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local test = require "integration_test"
local t_utils = require "integration_test.utils"
local clusters = require "st.zigbee.zcl.clusters"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local capabilities = require "st.capabilities"

local OnOff = clusters.OnOff
local Level = clusters.Level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local test = require "integration_test"
local t_utils = require "integration_test.utils"
local clusters = require "st.zigbee.zcl.clusters"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local capabilities = require "st.capabilities"

local OnOff = clusters.OnOff
local Level = clusters.Level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local t_utils = require "integration_test.utils"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local capabilities = require "st.capabilities"

local OnOff = clusters.OnOff
local Level = clusters.Level
Expand Down
57 changes: 27 additions & 30 deletions drivers/SmartThings/zigbee-switch/src/test/test_zll_rgb_bulb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,18 @@ test.register_coroutine_test(
end
)

test.register_coroutine_test(
"Set Hue command test",
function()
local test_data = {
{ hue = 75, saturation = 65, x = 0x3E51, y = 0x255D },
{ hue = 75, saturation = nil, x = 0x500F, y = 0x543B }
}

for _, data in ipairs(test_data) do
local test_data = {
{ hue = 75, saturation = 65, x = 0x3E51, y = 0x255D },
{ hue = 75, saturation = nil, x = 0x500F, y = 0x543B }
}

for _, data in ipairs(test_data) do
test.register_coroutine_test(
"Set Hue command test",
function()
if data.saturation ~= nil then
mock_device.wrapped_device.state_cache = {["main"] = {["colorControl"] = {["saturation"] = {["value"] = data.saturation}}}}
else
mock_device.wrapped_device.state_cache = {}
test.socket.zigbee:__queue_receive({mock_device.id, ColorControl.attributes.CurrentSaturation:build_test_attr_report(mock_device, math.ceil(data.saturation / 100 * 0xFE))})
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.colorControl.saturation(data.saturation)))
end

test.timer.__create_and_queue_test_time_advance_timer(0.2, "oneshot")
Expand Down Expand Up @@ -218,23 +217,21 @@ test.register_coroutine_test(

test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.attributes.CurrentX:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.attributes.CurrentY:read(mock_device) })
end
end
)

test.register_coroutine_test(
"Set Saturation command test",
function()
local test_data = {
{ hue = 75, saturation = 65, x = 0x3E51, y = 0x255D },
{ hue = nil, saturation = 65, x = 0x86EF, y = 0x5465 }
}
end
)
end

for _, data in ipairs(test_data) do
if data.saturation ~= nil then
mock_device.wrapped_device.state_cache = {["main"] = {["colorControl"] = {["hue"] = {["value"] = data.hue}}}}
else
mock_device.wrapped_device.state_cache = {}
test_data = {
{ hue = 75, saturation = 65, x = 0x3E51, y = 0x255D },
{ hue = nil, saturation = 65, x = 0x86EF, y = 0x5465 }
}
for _, data in ipairs(test_data) do
test.register_coroutine_test(
"Set Saturation command test",
function()
if data.hue ~= nil then
test.socket.zigbee:__queue_receive({mock_device.id, ColorControl.attributes.CurrentHue:build_test_attr_report(mock_device, math.ceil(data.hue / 100 * 0xFE))})
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.colorControl.hue(data.hue)))
end

test.timer.__create_and_queue_test_time_advance_timer(0.2, "oneshot")
Expand Down Expand Up @@ -265,8 +262,8 @@ test.register_coroutine_test(
test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.attributes.CurrentX:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, ColorControl.attributes.CurrentY:read(mock_device) })
end
end
)
)
end

test.register_coroutine_test(
"Set Hue/Saturation command test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
-- limitations under the License.

local clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"

local OnOff = clusters.OnOff
local Level = clusters.Level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local AEON_MULTIWHITE_BULB_FINGERPRINTS = {
local WARM_WHITE_CONFIG = 0x51
local COLD_WHITE_CONFIG = 0x52
local SWITCH_COLOR_QUERY_DELAY = 2
local DEFAULT_COLOR_TEMPERATURE = 2700

local function can_handle_aeon_multiwhite_bulb(opts, driver, device, ...)
for _, fingerprint in ipairs(AEON_MULTIWHITE_BULB_FINGERPRINTS) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.

local capabilities = require "st.capabilities"
local SwitchBinary = (require "st.zwave.CommandClass.SwitchBinary")({version=2,strict=true})
local SensorBinary = (require "st.zwave.CommandClass.SensorBinary")({version=2})

Expand Down
16 changes: 8 additions & 8 deletions drivers/SmartThings/zwave-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ local function do_configure(driver, device)
end
end

-- local initial_events_map = {
-- [capabilities.tamperAlert.ID] = capabilities.tamperAlert.tamper.clear(),
-- [capabilities.waterSensor.ID] = capabilities.waterSensor.water.dry(),
-- [capabilities.moldHealthConcern.ID] = capabilities.moldHealthConcern.moldHealthConcern.good(),
-- [capabilities.contactSensor.ID] = capabilities.contactSensor.contact.closed(),
-- [capabilities.smokeDetector.ID] = capabilities.smokeDetector.smoke.clear(),
-- [capabilities.motionSensor.ID] = capabilities.motionSensor.motion.inactive()
-- }
local initial_events_map = {
[capabilities.tamperAlert.ID] = capabilities.tamperAlert.tamper.clear(),
[capabilities.waterSensor.ID] = capabilities.waterSensor.water.dry(),
[capabilities.moldHealthConcern.ID] = capabilities.moldHealthConcern.moldHealthConcern.good(),
[capabilities.contactSensor.ID] = capabilities.contactSensor.contact.closed(),
[capabilities.smokeDetector.ID] = capabilities.smokeDetector.smoke.clear(),
[capabilities.motionSensor.ID] = capabilities.motionSensor.motion.inactive()
}

local function added_handler(self, device)
for id, event in pairs(initial_events_map) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
local test = require "integration_test"
local zw = require "st.zwave"
local zw_test_utils = require "integration_test.zwave_test_utils"
local capabilities = require "st.capabilities"
local Battery = (require "st.zwave.CommandClass.Battery")({version=1})
local Association = (require "st.zwave.CommandClass.Association")({version=2})
local SensorBinary = (require "st.zwave.CommandClass.SensorBinary")({version=2})
local WakeUp = (require "st.zwave.CommandClass.WakeUp")({version=1})
local t_utils = require "integration_test.utils"

Expand Down Expand Up @@ -86,7 +88,8 @@ test.register_coroutine_test(
"At a WakeUp, Assocation:Set shouldn't be sent when there was a motion status event",
function()
test.socket.zwave:__set_channel_ordering("relaxed")
mock_sensor.wrapped_device.state_cache = {["main"] = {["motionSensor"] = {["motion"] = {["value"] = "inactive"}}}}
test.socket.zwave:__queue_receive({mock_sensor.id, SensorBinary:Report({sensor_type=SensorBinary.sensor_type.MOTION, sensor_value=0x00})})
test.socket.capability:__expect_send(mock_sensor:generate_test_message("main", capabilities.motionSensor.motion.inactive()))
test.socket.zwave:__queue_receive({mock_sensor.id, WakeUp:Notification({}) })
test.socket.zwave:__expect_send(zw_test_utils.zwave_test_build_send_command(
mock_sensor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local test = require "integration_test"
local zw = require "st.zwave"
local zw_test_utils = require "integration_test.zwave_test_utils"
local capabilities = require "st.capabilities"
local SwitchBinary = (require "st.zwave.CommandClass.SwitchBinary")({version=2,strict=true})
local SensorBinary = (require "st.zwave.CommandClass.SensorBinary")({version=2})
local t_utils = require "integration_test.utils"
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-siren/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-- limitations under the License.

local capabilities = require "st.capabilities"
-- local cap_defaults = require "st.capabilities.defaults"
local cap_defaults = require "st.capabilities.defaults"
--- @type st.zwave.defaults
local defaults = require "st.zwave.defaults"
--- @type st.zwave.Driver
Expand Down

0 comments on commit 80f168a

Please sign in to comment.