Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for types.Atis validator #6

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pydantic import ValidationError

from vatsim.types import VatsimData, VatsimEndpoints
from vatsim.types import Atis, VatsimData, VatsimEndpoints


def test_fails_on_wrong_data():
Expand All @@ -11,3 +11,26 @@ def test_fails_on_wrong_data():

def test_validates_status_json(status_json: str):
VatsimEndpoints.model_validate_json(status_json)


def test_atis_validate_runways_in_use():
atis_data = {
"cid": 23,
"name": "Frank Nord",
"callsign": "ZZZZ_ATIS",
"frequency": "122.800",
"facility": 1,
"rating": 1,
"server": "unkown",
"visual_range": 100,
"atis_code": "Z",
"logon_time": "2032-04-20T04:20:00+0000",
"last_updated": "2032-04-20T04:20:00+0000",
"text_atis": None,
}
atis_no_text = Atis.model_validate(atis_data)
assert len(atis_no_text.runways_in_use) == 0

atis_data["text_atis"] = "RUNWAYS IN USE 26L AND 26R"
atis_with_text = Atis.model_validate(atis_data)
assert set(atis_with_text.runways_in_use) == {"26L", "26R"}