Skip to content

Commit

Permalink
Add extra sanity check for ooe_tbl test
Browse files Browse the repository at this point in the history
Compare the retrieved semi-major axis value (in AU) when the AU value
retrieved "manually" from the web interface for the same date
(2023-01-01).
  • Loading branch information
david-macmahon committed Apr 2, 2024
1 parent ce66385 commit bb49fc8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,36 @@ end

@testset "Osculating Orbital Elements table generation: ooe_tbl" begin
# Generate tables and save output to JWST.txt
t_start = DateTime(2024, 3, 13)
t_stop = Date(2024, 3, 14)
t_start = DateTime(2023, 1, 1)
t_stop = Date(2023, 1, 2)
δt = Hour(1)
local_file = ooe_tbl("JWST", t_start, t_stop, δt; CSV_FORMAT = true,
FILENAME = "jwst.csv", CENTER = "SSB")
local_file = ooe_tbl("JWST", t_start, t_stop, δt; FILENAME = "jwst.csv",
CSV_FORMAT = true, CENTER = "SSB", OUT_UNITS="AU-D")

@test isfile(local_file)

jwst = ooe_tbl("JWST", t_start, t_stop, δt; CSV_FORMAT = true, CENTER = "SSB")
jwst = ooe_tbl("JWST", t_start, t_stop, δt;
CSV_FORMAT = true, CENTER = "SSB", OUT_UNITS="AU-D")

x = readlines(local_file)
y = split(chomp(jwst), "\n")

@test length(x) == length(y)
# Find lines that differ
diffinds = findall(x .!= y)
# The only lines that should differ start with "Ephemeris / API_USER" and
# The only line(s) that should differ start with "Ephemeris / API_USER" and
# contain time of retrieval.
@test all(startswith("Ephemeris / API_USER"), y[diffinds])

# Test that A (semi-major axis) for t_start has expected value
soe = findfirst(==("\$\$SOE"), y)
a_fetched = parse(Float64, split(y[soe+1], ',')[12])
a_expected = 1.028281028256704E+00 # for 2023-01-01 (retrieved 2024-04-02)

# This test may fail if the "DEFINITIVE_EPHEMERIS" for past dates are ever
# updated/changed.
@test a_fetched a_expected

rm(local_file)
end

Expand Down

0 comments on commit bb49fc8

Please sign in to comment.