argos/tests/test_schemas_config.py
Alexis Métaireau 42ec15c6f4 Working SSL checks, refactoring of the codebase.
- Start implementing some tests using pytest
- Packaged using pyproject.toml
- Implemented SSL checks using httpx
- Checks can now run partially on the server, to access the configuration and determine the severity of the error if any
- Used black to format all the files
- Added an utility to convert strings like "3d" and "3w" to days
- The internal representation of SSL thresholds is now a list of tuples
- Models were lacking some relationship between Tasks and Results
2023-10-09 19:33:58 +02:00

16 lines
526 B
Python

import pytest
from argos.schemas.config import SSL
def test_ssl_duration_parsing():
data = {"thresholds": [{"2d": "warning"}, {"3w": "error"}]}
# Test the validation and parsing of SSL model
ssl_object = SSL(**data)
assert len(ssl_object.thresholds) == 2
assert ssl_object.thresholds == [(2, "warning"), (21, "error")]
# Test the constraint on severity
with pytest.raises(ValueError):
erroneous_data = {"thresholds": [{"1d": "caution"}, {"1w": "danger"}]}
SSL(**erroneous_data)