From dcb25854e58ec963eeac2534c6262bbe76b44428 Mon Sep 17 00:00:00 2001 From: Caspian Baska Date: Fri, 30 Jul 2021 16:08:47 +1000 Subject: [PATCH] test: remove sleeps --- drivers/cisco/meraki/meraki_locations_spec.cr | 2 -- drivers/cisco/switch/snooping_catalyst_spec.cr | 5 ----- drivers/denon/amplifier/av_receiver_spec.cr | 8 ++++---- drivers/exterity/avedia_player/r92xx_spec.cr | 6 +++--- drivers/exterity/avedia_player/r93xx_spec.cr | 6 +++--- drivers/global_cache/gc_100_spec.cr | 2 -- drivers/panasonic/display/protocol2_spec.cr | 4 ++-- drivers/place/mqtt_spec.cr | 1 - drivers/screen_technics/connect_spec.cr | 4 ++-- drivers/sharp/pn_series_spec.cr | 3 +-- drivers/sony/projector/serial_control_spec.cr | 5 +++-- 11 files changed, 18 insertions(+), 28 deletions(-) diff --git a/drivers/cisco/meraki/meraki_locations_spec.cr b/drivers/cisco/meraki/meraki_locations_spec.cr index e2447f3dad..5ef175d5de 100644 --- a/drivers/cisco/meraki/meraki_locations_spec.cr +++ b/drivers/cisco/meraki/meraki_locations_spec.cr @@ -19,8 +19,6 @@ DriverSpecs.mock_driver "Cisco::Meraki::Locations" do Dashboard: {DashboardMock}, }) - sleep 0.5 - # Should standardise the format of MAC addresses exec(:format_mac, "0x12:34:A6-789B").get.should eq %(1234a6789b) diff --git a/drivers/cisco/switch/snooping_catalyst_spec.cr b/drivers/cisco/switch/snooping_catalyst_spec.cr index b3c8cdee78..29bdf9c096 100644 --- a/drivers/cisco/switch/snooping_catalyst_spec.cr +++ b/drivers/cisco/switch/snooping_catalyst_spec.cr @@ -2,7 +2,6 @@ require "placeos-driver/spec" DriverSpecs.mock_driver "Cisco::Switch::SnoopingCatalyst" do transmit "SG-MARWFA61301>" - sleep 1.5.seconds should_send "show interfaces status\n" transmit "show interfaces status\n" @@ -30,8 +29,6 @@ Te4/1/4 connected trunk full 10G SFP-10GBase-S Po1 connected trunk a-full a-10G ) - sleep 3.1.seconds - should_send "show mac address-table\n" transmit "show mac address-table\n" @@ -40,8 +37,6 @@ Po1 connected trunk a-full a-10G 10 f4db.e618.10a4 DYNAMIC Te2/0/40 ) - sleep 3.1.seconds - should_send "show ip dhcp snooping binding\n" transmit %(MacAddress IpAddress Lease(sec) Type VLAN Interface ------------------ --------------- ---------- ------------- ---- -------------------- diff --git a/drivers/denon/amplifier/av_receiver_spec.cr b/drivers/denon/amplifier/av_receiver_spec.cr index 0c5f877790..b16e1ffa71 100644 --- a/drivers/denon/amplifier/av_receiver_spec.cr +++ b/drivers/denon/amplifier/av_receiver_spec.cr @@ -4,7 +4,7 @@ DriverSpecs.mock_driver "Denon::Amplifier::AvReceiver" do #### # POWER # - sleep 1.second + # query power exec(:power?) should_send("PW?") @@ -24,7 +24,7 @@ DriverSpecs.mock_driver "Denon::Amplifier::AvReceiver" do #### # INPUT # - sleep 1.second + # query input > DVD exec(:input?) should_send("SI?") @@ -39,7 +39,7 @@ DriverSpecs.mock_driver "Denon::Amplifier::AvReceiver" do #### # VOLUME # - sleep 1.second + # query exec(:volume?) should_send("MV?") @@ -54,7 +54,7 @@ DriverSpecs.mock_driver "Denon::Amplifier::AvReceiver" do #### # MUTE # - sleep 1.second + # query exec(:mute?) should_send("MU?") diff --git a/drivers/exterity/avedia_player/r92xx_spec.cr b/drivers/exterity/avedia_player/r92xx_spec.cr index 2bb5090ec5..8741145da4 100644 --- a/drivers/exterity/avedia_player/r92xx_spec.cr +++ b/drivers/exterity/avedia_player/r92xx_spec.cr @@ -10,16 +10,16 @@ DriverSpecs.mock_driver "Exterity::AvediaPlayer::R92xx" do status[:ready].should eq(false) responds("Exterity Control Interface\r") - sleep(2) + status[:ready].should eq(true) exec(:version) responds("^SoftwareVersion:123!\r") - sleep(2) + status[:version].should eq("123") exec(:tv_info) responds("^tv_info:a,b,c,d,e,f,g!\r") - sleep(2) + status[:tv_info].should eq("a,b,c,d,e,f,g") end diff --git a/drivers/exterity/avedia_player/r93xx_spec.cr b/drivers/exterity/avedia_player/r93xx_spec.cr index 090bfe06e7..d7ea2bcade 100644 --- a/drivers/exterity/avedia_player/r93xx_spec.cr +++ b/drivers/exterity/avedia_player/r93xx_spec.cr @@ -8,16 +8,16 @@ DriverSpecs.mock_driver "Exterity::AvediaPlayer::R92xx" do # this lets the driver know it's successfully connected status[:ready].should eq(false) responds("Terminal Control Interface\r") - sleep(2) + status[:ready].should eq(true) exec(:version) responds("^SoftwareVersion:123!\r") - sleep(2) + status[:version].should eq("123") exec(:tv_info) responds("^tv_info:a,b,c,d,e,f,g!\r") - sleep(2) + status[:tv_info].should eq("a,b,c,d,e,f,g") end diff --git a/drivers/global_cache/gc_100_spec.cr b/drivers/global_cache/gc_100_spec.cr index a40d836f62..2f60150ee1 100644 --- a/drivers/global_cache/gc_100_spec.cr +++ b/drivers/global_cache/gc_100_spec.cr @@ -10,8 +10,6 @@ DriverSpecs.mock_driver "GlobalCache::Gc100" do responds("endlistdevices\r") should_send("get_NET,0:1\r") - sleep 1 - status[:relay_config].should eq({ "relay" => {"0" => "2:1", "1" => "2:2", "2" => "2:3"}, "relaysensor" => {"0" => "1:1", "1" => "1:2", "2" => "1:3", "3" => "1:4"}, diff --git a/drivers/panasonic/display/protocol2_spec.cr b/drivers/panasonic/display/protocol2_spec.cr index 2bda8681e5..d216d97f3b 100644 --- a/drivers/panasonic/display/protocol2_spec.cr +++ b/drivers/panasonic/display/protocol2_spec.cr @@ -19,7 +19,7 @@ DriverSpecs.mock_driver "Panasonic::Display::Protocol2" do responds("NTCONTROL 1 09b075be\r") should_send("#{password}00PON\r") responds("00PON\r") - sleep 8.seconds + expect_reconnect responds("NTCONTROL 1 09b075be\r") should_send("#{password}00QPW\r") @@ -66,7 +66,7 @@ DriverSpecs.mock_driver "Panasonic::Display::Protocol2" do responds("NTCONTROL 1 09b075be\r") should_send("#{password}00POF\r") responds("00POF\r") - sleep 8.seconds + expect_reconnect responds("NTCONTROL 1 09b075be\r") should_send("#{password}00QPW\r") diff --git a/drivers/place/mqtt_spec.cr b/drivers/place/mqtt_spec.cr index f6d33f1e8e..2b0381e7c9 100644 --- a/drivers/place/mqtt_spec.cr +++ b/drivers/place/mqtt_spec.cr @@ -51,7 +51,6 @@ DriverSpecs.mock_driver "Place::MQTT" do publish.packet_length = publish.calculate_length transmit publish.to_slice - sleep 0.1 # wait a bit for processing status["root/topic"].should eq("testing") # ============================ diff --git a/drivers/screen_technics/connect_spec.cr b/drivers/screen_technics/connect_spec.cr index d57166adab..f4e0f22933 100644 --- a/drivers/screen_technics/connect_spec.cr +++ b/drivers/screen_technics/connect_spec.cr @@ -31,7 +31,7 @@ DriverSpecs.mock_driver "ScreenTechnics::Connect" do # * stop command # * down command # * status request - sleep 1.second + should_send("36, 19\r\n", timeout: 1.second) responds("136, 1, 19\r\n") @@ -41,7 +41,7 @@ DriverSpecs.mock_driver "ScreenTechnics::Connect" do # Execute the emergency stop and request another down request exec(:stop, index: 2, emergency: true) do |response| exec(:move, "Down", 2) - sleep 500.milliseconds + # --> respond to the down command responds("133, 1, 19, 1\r\n") diff --git a/drivers/sharp/pn_series_spec.cr b/drivers/sharp/pn_series_spec.cr index 88e390d7ac..6d2e1eea2d 100644 --- a/drivers/sharp/pn_series_spec.cr +++ b/drivers/sharp/pn_series_spec.cr @@ -15,7 +15,6 @@ DriverSpecs.mock_driver "Sharp::PnSeries" do }) # Retrying send_credentials - sleep 5 should_send("user\x0D\x0A") responds("OK\x0D\x0A") should_send("pass\x0D\x0A") @@ -43,7 +42,7 @@ DriverSpecs.mock_driver "Sharp::PnSeries" do should_send("INPS0010\x0D\x0A") responds("WAIT\x0D\x0A") responds("OK\x0D\x0A") - sleep 2 + should_send("INPS????\x0D\x0A") responds("INPS 10\x0D\x0A") status[:input].should eq("HDMI") diff --git a/drivers/sony/projector/serial_control_spec.cr b/drivers/sony/projector/serial_control_spec.cr index 20ba8289b3..15331691fc 100644 --- a/drivers/sony/projector/serial_control_spec.cr +++ b/drivers/sony/projector/serial_control_spec.cr @@ -6,7 +6,7 @@ DriverSpecs.mock_driver "Sony::Projector::SerialControl" do responds("\xA9\x00\x00\x03\x00\x00\x03\x9A") should_send("\xA9\x17\x2E\x00\x00\x00\x3F\x9A") responds("\xA9\x00\x00\x03\x00\x00\x03\x9A") - sleep 3 + # power? should_send("\xA9\x01\x02\x01\x00\x00\x03\x9A") responds("\xA9\x01\x02\x02\x00\x03\x03\x9A") @@ -17,6 +17,7 @@ DriverSpecs.mock_driver "Sony::Projector::SerialControl" do exec(:switch_to, "hdmi") should_send("\xA9\x00\x01\x00\x00\x03\x03\x9A") responds("\xA9\x00\x00\x03\x00\x00\x03\x9A") + # input? should_send("\xA9\x00\x01\x01\x00\x00\x01\x9A") responds("\xA9\x00\x01\x02\x00\x03\x03\x9A") @@ -38,7 +39,7 @@ DriverSpecs.mock_driver "Sony::Projector::SerialControl" do exec(:power, false) should_send("\xA9\x17\x2F\x00\x00\x00\x3F\x9A") responds("\xA9\x00\x00\x03\x00\x00\x03\x9A") - sleep 3 + # power? should_send("\xA9\x01\x02\x01\x00\x00\x03\x9A") responds("\xA9\x01\x02\x02\x00\x04\x07\x9A")