重构目录结构:调整项目布局
This commit is contained in:
55
tests/test_feeding_process.py
Normal file
55
tests/test_feeding_process.py
Normal file
@ -0,0 +1,55 @@
|
||||
# tests/test_feeding_process.py
|
||||
import unittest
|
||||
from unittest.mock import patch, MagicMock
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 添加src目录到Python路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
from src.control.feeding_controller import FeedingControlSystem
|
||||
|
||||
|
||||
class TestFeedingProcess(unittest.TestCase):
|
||||
|
||||
@patch('src.control.feeding_process.RelayController')
|
||||
@patch('src.control.feeding_process.InverterController')
|
||||
@patch('src.control.feeding_process.TransmitterController')
|
||||
def test_initialization(self, mock_transmitter, mock_inverter, mock_relay):
|
||||
"""测试初始化"""
|
||||
# 创建模拟对象
|
||||
mock_relay_instance = MagicMock()
|
||||
mock_relay.return_value = mock_relay_instance
|
||||
|
||||
mock_inverter_instance = MagicMock()
|
||||
mock_inverter.return_value = mock_inverter_instance
|
||||
|
||||
mock_transmitter_instance = MagicMock()
|
||||
mock_transmitter.return_value = mock_transmitter_instance
|
||||
|
||||
# 创建系统实例
|
||||
system = FeedingControlSystem()
|
||||
|
||||
# 验证初始化
|
||||
self.assertIsNotNone(system)
|
||||
self.assertFalse(system._running)
|
||||
|
||||
def test_set_feeding_parameters(self):
|
||||
"""测试设置下料参数"""
|
||||
with patch('src.control.feeding_process.RelayController'), \
|
||||
patch('src.control.feeding_process.InverterController'), \
|
||||
patch('src.control.feeding_process.TransmitterController'):
|
||||
system = FeedingControlSystem()
|
||||
system.set_feeding_parameters(
|
||||
target_vehicle_weight=3000,
|
||||
upper_buffer_weight=300,
|
||||
single_batch_weight=1500
|
||||
)
|
||||
|
||||
self.assertEqual(system.target_vehicle_weight, 3000)
|
||||
self.assertEqual(system.upper_buffer_weight, 300)
|
||||
self.assertEqual(system.single_batch_weight, 1500)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user