mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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
This commit is contained in:
0
tests/lasercodes/__init__.py
Normal file
0
tests/lasercodes/__init__.py
Normal file
15
tests/lasercodes/test_lasercoderegistry.py
Normal file
15
tests/lasercodes/test_lasercoderegistry.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
Reference in New Issue
Block a user