Initial commit
This commit is contained in:
commit
5303986377
20 changed files with 3195 additions and 0 deletions
53
tests/test_temp_norad.py
Normal file
53
tests/test_temp_norad.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"""Tests for the alphanumeric -> numeric TLE fallback."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from odm import (
|
||||
TEMP_NORAD_MAX,
|
||||
TEMP_NORAD_MIN,
|
||||
coerce_norad_to_int,
|
||||
temp_tle_norad,
|
||||
)
|
||||
|
||||
|
||||
def test_temp_norad_stays_in_reserved_range():
|
||||
for ident in ("A1234", "ZZ-9999", "1998-067A", "X", ""):
|
||||
n = temp_tle_norad(ident)
|
||||
assert TEMP_NORAD_MIN <= n <= TEMP_NORAD_MAX
|
||||
|
||||
|
||||
def test_temp_norad_is_deterministic():
|
||||
assert temp_tle_norad("A1234") == temp_tle_norad("A1234")
|
||||
assert temp_tle_norad("A1234") != temp_tle_norad("A1235")
|
||||
|
||||
|
||||
def test_coerce_norad_to_int_passes_through_numerics():
|
||||
assert coerce_norad_to_int(25544) == 25544
|
||||
assert coerce_norad_to_int("25544") == 25544
|
||||
assert coerce_norad_to_int(" 25544 ") == 25544
|
||||
|
||||
|
||||
def test_coerce_norad_to_int_substitutes_for_alphanumeric():
|
||||
n = coerce_norad_to_int("A1234")
|
||||
assert TEMP_NORAD_MIN <= n <= TEMP_NORAD_MAX
|
||||
# Stable: second call returns the same number.
|
||||
assert coerce_norad_to_int("A1234") == n
|
||||
|
||||
|
||||
def test_tle_from_gp_renders_for_alphanumeric_norad():
|
||||
"""The TLE rendering must succeed even when NORAD_CAT_ID is non-numeric."""
|
||||
from odm import parse_tle, tle_from_gp
|
||||
|
||||
iss = parse_tle(
|
||||
"ISS (ZARYA)",
|
||||
"1 25544U 98067A 24070.50000000 .00012345 00000-0 22000-3 0 9991",
|
||||
"2 25544 51.6400 200.0000 0001234 90.0000 270.0000 15.50000000400000",
|
||||
)
|
||||
gp = dict(iss.omm)
|
||||
gp["NORAD_CAT_ID"] = "A1234" # alphanumeric future ID
|
||||
_, line1, line2 = tle_from_gp(gp)
|
||||
assert line1.startswith("1 ") and line2.startswith("2 ")
|
||||
# The 5-digit slot at chars 2-7 must contain the synthetic 9xxxx number.
|
||||
assert line1[2:7].isdigit()
|
||||
assert 90000 <= int(line1[2:7]) <= 99999
|
||||
assert line1[2:7] == line2[2:7] # consistent across lines
|
||||
Loading…
Add table
Add a link
Reference in a new issue