feeding
This commit is contained in:
@ -13,7 +13,7 @@ class TestRelayController(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""测试前的准备工作"""
|
||||
self.relay_host = '192.168.0.18'
|
||||
self.relay_host = '192.168.250.62'
|
||||
self.relay_port = 50000
|
||||
self.relay = RelayController(host=self.relay_host, port=self.relay_port)
|
||||
|
||||
@ -24,7 +24,8 @@ class TestRelayController(unittest.TestCase):
|
||||
self.assertIsNotNone(self.relay.modbus_client)
|
||||
|
||||
# 检查设备映射
|
||||
self.assertIn(RelayController.DOOR_UPPER, self.relay.device_bit_map)
|
||||
self.assertIn(RelayController.UPPER_TO_JBL, self.relay.device_bit_map)
|
||||
self.assertIn(RelayController.UPPER_TO_ZD, self.relay.device_bit_map)
|
||||
self.assertIn(RelayController.DOOR_LOWER_1, self.relay.device_bit_map)
|
||||
self.assertIn(RelayController.DOOR_LOWER_2, self.relay.device_bit_map)
|
||||
self.assertIn(RelayController.BREAK_ARCH_UPPER, self.relay.device_bit_map)
|
||||
@ -62,7 +63,7 @@ class TestRelayController(unittest.TestCase):
|
||||
"""测试控制有效设备和动作"""
|
||||
with patch.object(self.relay, 'send_command') as mock_send:
|
||||
# 测试打开上料斗门
|
||||
self.relay.control(RelayController.DOOR_UPPER, 'open')
|
||||
self.relay.control(RelayController.UPPER_TO_JBL, 'open')
|
||||
mock_send.assert_called_once()
|
||||
|
||||
def test_control_invalid_device(self):
|
||||
@ -76,7 +77,7 @@ class TestRelayController(unittest.TestCase):
|
||||
"""测试控制无效动作"""
|
||||
with patch.object(self.relay, 'send_command') as mock_send:
|
||||
# 测试无效动作
|
||||
self.relay.control(RelayController.DOOR_UPPER, 'invalid_action')
|
||||
self.relay.control(RelayController.UPPER_TO_JBL, 'invalid_action')
|
||||
mock_send.assert_not_called()
|
||||
|
||||
@patch.object(RelayController, 'send_command')
|
||||
@ -89,7 +90,8 @@ class TestRelayController(unittest.TestCase):
|
||||
|
||||
# 验证返回的状态字典
|
||||
self.assertIsInstance(status, dict)
|
||||
self.assertIn(RelayController.DOOR_UPPER, status)
|
||||
self.assertIn(RelayController.UPPER_TO_JBL, status)
|
||||
self.assertIn(RelayController.UPPER_TO_ZD, status)
|
||||
mock_send_command.assert_called_once_with(self.relay.read_status_command)
|
||||
|
||||
@patch.object(RelayController, 'send_command')
|
||||
|
||||
Reference in New Issue
Block a user