-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_config_validator.py
41 lines (35 loc) · 1.19 KB
/
test_config_validator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pytest
from config_validator import validate_webhook_urls, ConfigValidationError
def test_valid_urls():
config = {
"microphone": {"webhook_url": "http://example.com/webhook"},
"rtsp_sources": [
{"name": "cam1", "webhook_url": "http://example.com/webhook1"},
{"name": "cam2", "webhook_url": "https://example.com/webhook2"}
],
"saved_vban_sources": [
{"name": "source1", "webhook_url": "http://localhost:8123/webhook"}
],
"vban": {"webhook_url": "http://192.168.1.100:8080/webhook"}
}
# Should not raise any exception
validate_webhook_urls(config)
def test_invalid_urls():
config = {
"microphone": {"webhook_url": "invalid-url"},
"rtsp_sources": [
{"name": "cam1", "webhook_url": "not-a-url"}
]
}
with pytest.raises(ConfigValidationError):
validate_webhook_urls(config)
def test_optional_urls():
config = {
"microphone": {"webhook_url": None},
"rtsp_sources": [
{"name": "cam1", "webhook_url": None}
],
"vban": {}
}
# Should not raise any exception
validate_webhook_urls(config)