dcs-retribution/tests/lasercodes/test_lasercoderegistry.py
Dan Albert 279572ae09
Add tests for LaserCodeRegistry, clean up.
* Store a deque rather than an iterator so it can be pickled
* Remove mangling from staticmethod (and rename now that it's no longer
  a generator)
* Rename "get" to "alloc" to make the mutation clear
* Move to its own package (the changes I'm working on make this no
  longer mission generator specific)
* Remove useless exception class. It's never caught so the unique type
  isn't needed
2023-10-01 20:11:37 +02:00

16 lines
527 B
Python

from game.lasercodes.lasercoderegistry import LaserCodeRegistry
def test_initial_laser_codes() -> None:
reg = LaserCodeRegistry()
assert list(reg.available_codes)[:5] == [1688, 1687, 1686, 1685, 1684]
assert list(reg.available_codes)[-5:] == [1715, 1714, 1713, 1712, 1711]
assert len(reg.available_codes) == 192
def test_alloc_laser_code() -> None:
reg = LaserCodeRegistry()
assert reg.alloc_laser_code() == 1688
assert 1688 not in reg.available_codes
assert len(reg.available_codes) == 191