Skip to content

Commit ec82fa5

Browse files
author
Alvaro Arroyo Parejo
committed
update remote tests and test data
1 parent ea69c0f commit ec82fa5

File tree

3 files changed

+47
-25
lines changed

3 files changed

+47
-25
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Last Update: 2021-10-04 05:49 UTC
1+
Last Update: 2022-08-19 08:03 UTC
22
Object | Diameter | VI Max |
33
Num/des. Name | m | *=Y | Date/Time | IP max | PS max |TS | Vel km/s |
44
AAAAAAAAA AAAAAAAAAAAAAAAA | NNNN | A | YYYY-MM-DD HH:MM | EEEEEEEE | NNN.NN | NN | NNN.NN |
5+
101955 Bennu | 484 | | 2182-09-24 20:24 | 3.70E-4 | -1.59 | | 12.68 |
6+
29075 1950DA | 1300 | | 2880-03-16 23:48 | 1.96E-5 | -2.13 | | 17.99 |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Last Update: 2022-04-04 10:00 UTC
2+
Object designator | Diameter in m | Impact date/time in UTC | Impact Velocity in km/s | Estimated energy in Mt | Measured energy in Mt |
3+
2022EB5 | 1.9* | 2022-03-11 21:22:00 | 18.53 | 2.96E-4 | 4.00E-3 |
4+
2019MO | 5* | 2019-06-22 21:30:00 | 16.34 | 3.82E-3 | 6.00E-3 |
5+
2018LA | 2.8* | 2018-06-02 16:44:00 | 16.98 | 8.90E-4 | 9.80E-4 |
6+
2014AA | 2.3* | 2014-01-02 02:30:00 | 11.97 | 2.44E-4 | n/a |
7+
2008TC3 | 3* | 2008-10-07 02:45:00 | 11.77 | 6.77E-4 | 1.00E-3 |

astroquery/esa/neocc/test/test_neocc_remote.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
* Property: European Space Agency (ESA)
88
* Developed by: Elecnor Deimos
99
* Author: C. Álvaro Arroyo Parejo
10-
* Date: 02-11-2021
10+
* Date: 21-08-2022
1111
12-
© Copyright [European Space Agency][2021]
12+
© Copyright [European Space Agency][2022]
1313
All rights reserved
1414
"""
1515

16-
1716
import io
1817
import os
1918
import re
20-
2119
import random
2220
import pytest
21+
import astropy
22+
23+
from astropy.table import Table
2324
import pandas as pd
2425
import pandas.testing as pdtesting
2526
import pandas.api.types as ptypes
@@ -28,8 +29,6 @@
2829
from astroquery.esa.neocc.__init__ import conf
2930
from astroquery.esa.neocc import neocc, lists, tabs
3031

31-
import astropy
32-
3332
# Import BASE URL and TIMEOUT
3433
API_URL = conf.API_URL
3534
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
@@ -52,7 +51,7 @@ class TestLists:
5251
"priority_list": 'esa_priority_neo_list',
5352
"priority_list_faint": 'esa_faint_neo_list',
5453
"close_encounter" : 'close_encounter2.txt',
55-
"impacted_objects" : 'impactedObjectsList.txt',
54+
"impacted_objects" : 'past_impactors_list',
5655
"neo_catalogue_current" : 'neo_kc.cat',
5756
"neo_catalogue_middle" : 'neo_km.cat'
5857
}
@@ -127,8 +126,11 @@ def test_parse_list(self):
127126
verify=VERIFICATION).content
128127
# Decode the data using UTF-8
129128
data_list_d = io.StringIO(data_list.decode('utf-8'))
130-
131-
assert isinstance(lists.parse_list(url, data_list_d),
129+
if url == 'impacted_objects':
130+
assert isinstance(lists.parse_list(url, data_list_d),
131+
Table)
132+
else:
133+
assert isinstance(lists.parse_list(url, data_list_d),
132134
pd.DataFrame)
133135
# Invalid inputs
134136
bad_names = ["ASedfe", "%&$", "ÁftR+", 154]
@@ -222,9 +224,22 @@ def test_parse_risk(self):
222224
new_list['Date/Time'])
223225

224226
else:
225-
# Currently risk special list is empty
226-
assert new_list.empty
227+
# Assert dataframe is not empty, columns names
228+
assert not new_list.empty
227229
assert (new_list.columns == risk_special_columns).all()
230+
# Assert columns data types
231+
# Floats
232+
float_cols = ['IP max', 'PS max', 'Vel in km/s']
233+
assert all(ptypes.is_float_dtype(new_list[cols1])\
234+
for cols1 in float_cols)
235+
# int64
236+
int_cols = ['Diameter in m']
237+
assert all(ptypes.is_int64_dtype(new_list[cols2])\
238+
for cols2 in int_cols)
239+
# Object
240+
object_cols = ['Object Name', '*=Y', 'TS']
241+
assert all(ptypes.is_object_dtype(new_list[cols3])\
242+
for cols3 in object_cols)
228243

229244

230245
def test_parse_clo(self):
@@ -254,7 +269,7 @@ def test_parse_clo(self):
254269
# Assert dataframe is not empty, columns names and length
255270
assert not new_list.empty
256271
assert (new_list.columns == close_columns).all()
257-
assert len(new_list.index) > 100
272+
assert len(new_list.index) > 10
258273
# Assert Connection Error. In case of internal server error
259274
# the request provided an empty file
260275
foo_error = io.StringIO('This site cant be reached\n'
@@ -383,15 +398,11 @@ def test_parse_impacted(self):
383398
# Parse using parse_nea
384399
new_list = lists.parse_impacted(data_list_d)
385400
# Assert is a pandas DataFrame
386-
assert isinstance(new_list, pd.DataFrame)
401+
assert isinstance(new_list, Table)
387402
# Assert dataframe is not empty and length
388-
assert not new_list.empty
389-
assert len(new_list.index) < 100
390-
# Assert columns data types
391-
# Object
392-
assert ptypes.is_object_dtype(new_list[0])
393-
# Datetime
394-
assert ptypes.is_datetime64_ns_dtype(new_list[1])
403+
# Assert dataframe is not empty, columns names and length
404+
assert len(new_list) != 0
405+
assert len(new_list) < 100
395406

396407

397408
def test_parse_neo_catalogue(self):
@@ -460,14 +471,16 @@ def test_get_object_url(self):
460471
'observations', 'orbit_properties', '&cefrgfe',
461472
4851]
462473
# Possible additional argument
474+
orbital_element = ['keplerian', 'equinoctial']
463475
orbit_epoch = ['present', 'middle']
464476
# Iterate to obtain all possible urls
465477
for tab in object_tabs:
466478
if tab == 'orbit_properties':
467-
for epoch in orbit_epoch:
468-
with pytest.raises(ValueError):
469-
tabs.get_object_url(rnd_object, tab,
470-
orbital_elements=None, orbit_epoch=epoch)
479+
for element in orbital_element:
480+
for epoch in orbit_epoch:
481+
with pytest.raises(ValueError):
482+
tabs.get_object_url(rnd_object, tab,
483+
orbital_elements=None, orbit_epoch=epoch)
471484
elif tab in ['&cefrgfe', 4851]:
472485
with pytest.raises(KeyError):
473486
tabs.get_object_url(rnd_object, tab)

0 commit comments

Comments
 (0)