| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- from hookvision.config_loader import load_config
- from hookvision.models import ModuleType, CameraPosition
- class TestLoadConfig:
- def test_load_rfid_config(self, sample_config_path):
- config = load_config(sample_config_path)
- assert config.app_name == "测试系统"
- assert config.module_type == ModuleType.RFID
- assert config.rfid is not None
- assert config.rfid.ip == "192.168.1.1"
- assert config.rfid.port == 60000
- assert config.modbus is None
- assert config.ai.enabled is False
- def test_load_buckets(self, sample_config_path):
- config = load_config(sample_config_path)
- assert len(config.buckets) == 1
- bucket = config.buckets[0]
- assert bucket.id == 1
- assert bucket.description == "测试工位"
- assert bucket.code_x == "TEST001"
- assert len(bucket.cameras) == 2
- def test_load_cameras(self, sample_config_path):
- config = load_config(sample_config_path)
- bucket = config.buckets[0]
- left = next(c for c in bucket.cameras if c.position == CameraPosition.LEFT)
- right = next(c for c in bucket.cameras if c.position == CameraPosition.RIGHT)
- assert left.rtsp_url == "rtsp://test:test@192.168.1.10:554/stream1"
- assert left.topic == "test/left"
- assert right.rtsp_url == "rtsp://test:test@192.168.1.11:554/stream2"
- assert right.topic == "test/right"
- def test_load_video_config(self, sample_config_path):
- config = load_config(sample_config_path)
- assert config.video.rtsp_timeout == 5.0
- def test_config_file_not_exists(self, tmp_path):
- from configparser import NoSectionError
- path = tmp_path / "nonexistent.ini"
- import pytest
- with pytest.raises(NoSectionError):
- load_config(str(path))
|