Skip to content

Commit 37b4640

Browse files
committed
test updates
1 parent 982f2d4 commit 37b4640

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/linkhub_prometheus_exporter/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
settings_files=["settings.toml", ".secrets.toml"],
66
# Validating and setting defaults
77
validators=[
8-
Validator("REQUEST_KEY", is_type_of=str, must_exist=True),
8+
Validator("REQUEST_KEY", is_type_of=str),
99
Validator("POLLING_INTERVAL_SECONDS", is_type_of=int, default=5),
1010
Validator("BOX_ADDRESS", is_type_of=str, default="192.168.1.1"),
1111
Validator("EXPORTER_PORT", is_type_of=int, default=9877),

src/linkhub_prometheus_exporter/exporter.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,17 @@ def main():
145145
"""Main entry point for the exporter"""
146146
logging.info("Linkhub Prometheus Exporter, version %s", __version__)
147147

148-
router_metrics = RouterMetrics(
149-
request_key=settings.REQUEST_KEY,
150-
box_addr=settings.BOX_ADDRESS,
151-
polling_interval_seconds=settings.POLLING_INTERVAL_SECONDS,
152-
)
148+
try:
149+
router_metrics = RouterMetrics(
150+
request_key=settings.REQUEST_KEY,
151+
box_addr=settings.BOX_ADDRESS,
152+
polling_interval_seconds=settings.POLLING_INTERVAL_SECONDS,
153+
)
154+
except AttributeError as exc:
155+
# Every other setting besides REQUEST_KEY has defaults
156+
logging.error("Missing REQUEST_KEY configuration.")
157+
raise RuntimeError("Missing REQUEST_KEY configuration.") from exc
158+
153159
start_http_server(
154160
port=settings.EXPORTER_PORT, addr=settings.EXPORTER_ADDRESS
155161
)

tests/test_basic.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from linkhub_prometheus_exporter.exporter import RouterMetrics
55

66
# Test payload data
7+
# Exported & modified from real requests
78
NETWORK_INFO = {
89
"PLMN": "12345",
910
"NetworkType": 8,

0 commit comments

Comments
 (0)