Skip to content

Commit

Permalink
Fixed unit tests to test all new sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Little-Ryugu committed Dec 18, 2024
1 parent b801d4f commit 06f227c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
6 changes: 0 additions & 6 deletions tests/data/orbit_test_files/orbit_sanity_check_com.csv

This file was deleted.

3 changes: 3 additions & 0 deletions tests/data/orbit_test_files/orbit_sanity_check_com_e<0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ObjID,FORMAT,q,e,inc,node,argPeri,t_p_MJD_TDB,epochMJD_TDB
S00000t,COM,0.952105479028,-0.504888475701,4.899098347472,148.881068605772,39.949789586436,54486.32292808,54466.0

3 changes: 3 additions & 0 deletions tests/data/orbit_test_files/orbit_sanity_check_com_q<0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ObjID,FORMAT,q,e,inc,node,argPeri,t_p_MJD_TDB,epochMJD_TDB
S00000t,COM,-0.952105479028,0.504888475701,4.899098347472,148.881068605772,39.949789586436,54486.32292808,54466.0

2 changes: 0 additions & 2 deletions tests/data/orbit_test_files/orbit_sanity_check_kep.des

This file was deleted.

2 changes: 2 additions & 0 deletions tests/data/orbit_test_files/orbit_sanity_check_kep_e<0.des
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ObjID a e inc node argPeri ma epochMJD_TDB FORMAT
2010_TU149 2.2103867 -1 1.9679 58.91911 92.60419 324.21145 60200 KEP
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ObjID a e inc node argPeri ma epochMJD_TDB FORMAT
2010_TU149 -2.2103867 0.5 1.9679 58.91911 92.60419 324.21145 60200 KEP
2 changes: 2 additions & 0 deletions tests/data/orbit_test_files/orbit_sanity_check_kep_e=1.des
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ObjID a e inc node argPeri ma epochMJD_TDB FORMAT
2010_TU149 2.2103867 1 1.9679 58.91911 92.60419 324.21145 60200 KEP
2 changes: 2 additions & 0 deletions tests/data/orbit_test_files/orbit_sanity_check_kep_e>1.des
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ObjID a e inc node argPeri ma epochMJD_TDB FORMAT
2010_TU149 2.2103867 2 1.9679 58.91911 92.60419 324.21145 60200 KEP
33 changes: 29 additions & 4 deletions tests/readers/test_OrbitAuxReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,44 @@ def test_orbit_reader_wrong_delim():
def test_orbit_sanity_check_kep():
"""If an orbit parameter is undefined, raise an exception"""

#for keplerian
#for keplerian e==1
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_kep.des"),"whitespace")
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_kep_e=1.des"),"whitespace")
_.read_rows()
assert err.value.code == "ERROR: Invalid Keplerian elements detected for one or more objects (check log for information)"

#for keplerian e<0
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_kep_e<0.des"),"whitespace")
_.read_rows()
assert err.value.code == "ERROR: Invalid Keplerian elements detected for one or more objects (check log for information)"

#for keplerian e>1
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_kep_e>1.des"),"whitespace")
_.read_rows()
assert err.value.code == "ERROR: Invalid Keplerian elements detected for one or more objects (check log for information)"

#for keplerian e<1 a<0
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_kep_e<1_a<0.des"),"whitespace")
_.read_rows()
assert err.value.code == "ERROR: Invalid Keplerian elements detected for one or more objects (check log for information)"



def test_orbit_sanity_check_com():
"""If an orbit parameter is undefined, raise an exception"""

#for comentary
#for comentary q<0
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_com.csv"),"csv")
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_com_q<0.csv"),"csv")
_.read_rows()
assert err.value.code == "ERROR: Invalid cometary elements detected for one or more objects (check log for information)"

#for comentary e<0
with pytest.raises(SystemExit) as err:
_ = OrbitAuxReader(get_test_filepath("orbit_test_files/orbit_sanity_check_com_e<0.csv"),"csv")
_.read_rows()
assert err.value.code == "ERROR: Invalid cometary elements detected for one or more objects (check log for information)"

0 comments on commit 06f227c

Please sign in to comment.