Skip to content

Commit d301dc5

Browse files
committed
test_queries.py modified
1 parent 53e4009 commit d301dc5

File tree

1 file changed

+87
-7
lines changed

1 file changed

+87
-7
lines changed

tests/test_queries.py

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,23 @@ def test_query_datetime (datalevel, datetime, capsys):
6767

6868
assert os.path.exists(outpath), \
6969
f'Result not downloaded to file [{outpath:s}]'
70-
assert (filecmp.cmp (outpath, datapath, shallow=False))
70+
71+
if (datalevel == 'l0'):
72+
assert (filecmp.cmp (outpath, datapath, shallow=False))
73+
74+
elif (datalevel == 'l1'):
75+
astropytbl = None
76+
astropytbl = Table.read (outpath, format='ascii.ipac')
77+
assert (astropytbl is not None), \
78+
"f{outpath:s} cannot be read by astropy"
79+
80+
astropytbl_truth = None
81+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
82+
assert (astropytbl_truth is not None), \
83+
"f{datapath:s} cannot be read by astropy"
7184

85+
assert (len(astropytbl) == len(astropytbl_truth)), \
86+
f"Number of records in {outpath:s} is incorrect"
7287

7388
#
7489
# test query_position method for all datalevel;
@@ -97,7 +112,20 @@ def test_query_position (datalevel, pos, capsys):
97112

98113
assert os.path.exists(outpath), \
99114
f'Result not downloaded to file [{outpath:s}]'
100-
assert (filecmp.cmp (outpath, datapath, shallow=False))
115+
#assert (filecmp.cmp (outpath, datapath, shallow=False))
116+
117+
astropytbl = None
118+
astropytbl = Table.read (outpath, format='ascii.ipac')
119+
assert (astropytbl is not None), \
120+
"f{outpath:s} cannot be read by astropy"
121+
122+
astropytbl_truth = None
123+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
124+
assert (astropytbl_truth is not None), \
125+
"f{datapath:s} cannot be read by astropy"
126+
127+
assert (len(astropytbl) >= len(astropytbl_truth)), \
128+
f"Number of records in {outpath:s} is incorrect"
101129

102130

103131
#
@@ -116,7 +144,20 @@ def test_query_object():
116144

117145
assert os.path.exists(outpath), \
118146
f'Result not downloaded to file [{outpath:s}]'
119-
assert (filecmp.cmp (outpath, datapath, shallow=False))
147+
#assert (filecmp.cmp (outpath, datapath, shallow=False))
148+
149+
astropytbl = None
150+
astropytbl = Table.read (outpath, format='ascii.ipac')
151+
assert (astropytbl is not None), \
152+
"f{outpath:s} cannot be read by astropy"
153+
154+
astropytbl_truth = None
155+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
156+
assert (astropytbl_truth is not None), \
157+
"f{datapath:s} cannot be read by astropy"
158+
159+
assert (len(astropytbl) >= len(astropytbl_truth)), \
160+
f"Number of records in {outpath:s} is incorrect"
120161

121162

122163
#
@@ -135,7 +176,20 @@ def test_query_qobject():
135176

136177
assert os.path.exists(outpath), \
137178
f'Result not downloaded to file [{outpath:s}]'
138-
assert (filecmp.cmp (outpath, datapath, shallow=False))
179+
#assert (filecmp.cmp (outpath, datapath, shallow=False))
180+
181+
astropytbl = None
182+
astropytbl = Table.read (outpath, format='ascii.ipac')
183+
assert (astropytbl is not None), \
184+
"f{outpath:s} cannot be read by astropy"
185+
186+
astropytbl_truth = None
187+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
188+
assert (astropytbl_truth is not None), \
189+
"f{datapath:s} cannot be read by astropy"
190+
191+
assert (len(astropytbl) >= len(astropytbl_truth)), \
192+
f"Number of records in {outpath:s} is incorrect"
139193

140194
#
141195
# test query_program method using l1 data
@@ -147,13 +201,26 @@ def test_query_program():
147201

148202
Neid.query_program ('l1', \
149203
'2021A-2014', \
150-
cookiepath='./neidtestcookie.txt', \
204+
cookiepath='./neidadmincookie.txt', \
151205
format='ipac', \
152206
outpath=outpath)
153207

154208
assert os.path.exists(outpath), \
155209
f'Result not downloaded to file [{outpath:s}]'
156-
assert (filecmp.cmp (outpath, datapath, shallow=False))
210+
#assert (filecmp.cmp (outpath, datapath, shallow=False))
211+
212+
astropytbl = None
213+
astropytbl = Table.read (outpath, format='ascii.ipac')
214+
assert (astropytbl is not None), \
215+
"f{outpath:s} cannot be read by astropy"
216+
217+
astropytbl_truth = None
218+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
219+
assert (astropytbl_truth is not None), \
220+
"f{datapath:s} cannot be read by astropy"
221+
222+
assert (len(astropytbl) >= len(astropytbl_truth)), \
223+
f"Number of records in {outpath:s} is incorrect"
157224

158225

159226
#
@@ -196,7 +263,20 @@ def test_qeury_adql():
196263

197264
assert os.path.exists(outpath), \
198265
f'Result not downloaded to file [{outpath:s}]'
199-
assert (filecmp.cmp (outpath, datapath, shallow=False))
266+
#assert (filecmp.cmp (outpath, datapath, shallow=False))
267+
268+
astropytbl = None
269+
astropytbl = Table.read (outpath, format='ascii.ipac')
270+
assert (astropytbl is not None), \
271+
"f{outpath:s} cannot be read by astropy"
272+
273+
astropytbl_truth = None
274+
astropytbl_truth = Table.read (datapath, format='ascii.ipac')
275+
assert (astropytbl_truth is not None), \
276+
"f{datapath:s} cannot be read by astropy"
277+
278+
assert (len(astropytbl) >= len(astropytbl_truth)), \
279+
f"Number of records in {outpath:s} is incorrect"
200280

201281
#
202282
# test query_adql method:

0 commit comments

Comments
 (0)