Download sdk/python/tests/test_health.py from yusufcalisir/Collaborative-Fraud-Intelligence-Simulator: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/resolve/main/sdk/python/tests/test_health.py
- Command line
-
hf download hf://spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/sdk/python/tests/test_health.py
-
curl -L -o test_health.py https://huggingface.co/spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/resolve/main/sdk/python/tests/test_health.py
1.83 kB
| """Unit tests for ConnectorHealthMonitor and ConnectorHealthStatus.""" | |
| from unittest.mock import patch | |
| from cfi_connector_sdk.health import ConnectorHealthMonitor, ConnectorHealthStatus | |
| def test_connector_health_status_defaults(): | |
| status = ConnectorHealthStatus() | |
| assert status.status == "HEALTHY" | |
| assert status.broker_connected is True | |
| assert status.cert_days_remaining == 365 | |
| assert status.last_ping_timestamp is not None | |
| def test_health_monitor_report_healthy(mock_cert, mock_ping): | |
| monitor = ConnectorHealthMonitor(broker_host="127.0.0.1", broker_port=5672) | |
| report = monitor.get_health_report() | |
| assert report.status == "HEALTHY" | |
| assert report.broker_connected is True | |
| assert report.cert_days_remaining == 365 | |
| def test_health_monitor_report_unhealthy_broker(mock_cert, mock_ping): | |
| monitor = ConnectorHealthMonitor(broker_host="127.0.0.1", broker_port=5672) | |
| report = monitor.get_health_report() | |
| assert report.status == "UNHEALTHY" | |
| assert report.broker_connected is False | |
| def test_health_monitor_report_degraded_cert(mock_cert, mock_ping): | |
| monitor = ConnectorHealthMonitor(broker_host="127.0.0.1", broker_port=5672) | |
| report = monitor.get_health_report() | |
| assert report.status == "DEGRADED" | |
| assert report.broker_connected is True | |
| assert report.cert_days_remaining == 3 | |