mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Export airfield data to yaml, switch to ID keys.
This exports all the old AIRFIELD_DATA to yaml files. It's easier for users to send fixes if it's defined this way, and they can also fix it in their install without having to wait for a new release. This also switches the indexes from the unstable DCS airfield names to airfield IDs, so this fixes another case of DCS updates occasionally breaking Liberation. I also ended up finding quite a few typos in airfield names, and incorrect theater names in the process. Those have been fixed.
This commit is contained in:
36
tests/test_radios.py
Normal file
36
tests/test_radios.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import Callable
|
||||
|
||||
import pytest
|
||||
|
||||
from game.radio.radios import MHz, RadioFrequency, kHz
|
||||
|
||||
|
||||
@pytest.mark.parametrize("units,factory", [("kHz", kHz), ("MHz", MHz)])
|
||||
def test_radio_parsing(units: str, factory: Callable[..., RadioFrequency]) -> None:
|
||||
assert RadioFrequency.parse(f"0 {units}") == factory(0)
|
||||
assert RadioFrequency.parse(f"0.0 {units}") == factory(0)
|
||||
assert RadioFrequency.parse(f"255 {units}") == factory(255)
|
||||
assert RadioFrequency.parse(f"255.5 {units}") == factory(255, 500)
|
||||
assert RadioFrequency.parse(f"255.500 {units}") == factory(255, 500)
|
||||
assert RadioFrequency.parse(f"255.050 {units}") == factory(255, 50)
|
||||
assert RadioFrequency.parse(f"255.005 {units}") == factory(255, 5)
|
||||
assert RadioFrequency.parse(f"255.0 {units}") == factory(255)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse("")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse("255")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f" 255 {units}")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f"255 {units} ")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f"255 {units.lower()}")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f"255. {units}")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f".0 {units}")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f"0. {units}")
|
||||
with pytest.raises(ValueError):
|
||||
RadioFrequency.parse(f"255.5555 {units}")
|
||||
@@ -1,3 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from game.radio.tacan import (
|
||||
OutOfTacanChannelsError,
|
||||
TacanBand,
|
||||
@@ -6,8 +8,6 @@ from game.radio.tacan import (
|
||||
TacanRegistry,
|
||||
TacanUsage,
|
||||
)
|
||||
import pytest
|
||||
|
||||
|
||||
ALL_VALID_X_TR = [1, *range(31, 46 + 1), *range(64, 126 + 1)]
|
||||
ALL_VALID_X_A2A = [*range(37, 63 + 1), *range(100, 126 + 1)]
|
||||
@@ -75,3 +75,29 @@ def test_reserve_again() -> None:
|
||||
with pytest.raises(TacanChannelInUseError):
|
||||
registry.mark_unavailable(TacanChannel(1, TacanBand.X))
|
||||
registry.mark_unavailable(TacanChannel(1, TacanBand.X))
|
||||
|
||||
|
||||
def test_tacan_parsing() -> None:
|
||||
assert TacanChannel.parse("1X") == TacanChannel(1, TacanBand.X)
|
||||
assert TacanChannel.parse("1Y") == TacanChannel(1, TacanBand.Y)
|
||||
assert TacanChannel.parse("10X") == TacanChannel(10, TacanBand.X)
|
||||
assert TacanChannel.parse("100X") == TacanChannel(100, TacanBand.X)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1000X")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("0X")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1Z")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("X")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1 X")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse(" 1X")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1X ")
|
||||
with pytest.raises(ValueError):
|
||||
TacanChannel.parse("1x")
|
||||
|
||||
Reference in New Issue
Block a user