Skip to content

Commit 661b117

Browse files
committed
TST: fixing up tests to make them pass
1 parent ffab988 commit 661b117

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

astroquery/neodys/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
NEODyS Query Tool
3-
---------------
3+
-----------------
44
55
:Author: B612 Foundation
66

astroquery/neodys/core.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import requests
21
from . import conf
32
from ..query import BaseQuery
43

@@ -11,9 +10,6 @@ class NEODySClass(BaseQuery):
1110
NEODYS_URL = conf.server
1211
TIMEOUT = conf.timeout
1312

14-
def __init__(self):
15-
super(NEODySClass, self).__init__()
16-
1713
def query_object(self, object_id, orbital_element_type="eq", epoch_near_present=0):
1814
"""
1915
Parameters
@@ -70,7 +66,6 @@ def query_object(self, object_id, orbital_element_type="eq", epoch_near_present=
7066

7167
COV = []
7268
COR = []
73-
NOR = []
7469

7570
if orbital_element_type != 'ke' and orbital_element_type != 'eq':
7671
raise ValueError("OrbitElementType must be ke or eq")

astroquery/neodys/setup_package.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
import os
3+
4+
5+
def get_package_data():
6+
paths_test = [os.path.join('data', '2018vp1_eq0.txt')]
7+
8+
return {'astroquery.neodys.tests': paths_test}
Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
import os
33

4-
from ...utils.testing_tools import MockResponse
4+
import numpy as np
55

6-
from ... import neodys
6+
from astroquery.utils.mocks import MockResponse
7+
from astroquery.neodys import NEODySClass, NEODyS
78

89
DATA_FILE = '2018vp1_eq0.txt'
910

@@ -24,28 +25,24 @@ def nonremote_request(self, request_type, url, **kwargs):
2425
# that mocks(monkeypatches) the actual 'requests.get' function:
2526
@pytest.fixture
2627
def patch_request(request):
27-
try:
28-
mp = request.getfixturevalue("monkeypatch")
29-
except AttributeError:
30-
mp = request.getfuncargvalue("monkeypatch")
31-
mp.setattr(neodys.core.NEODySClass, '_request',
32-
nonremote_request)
28+
mp = request.getfixturevalue("monkeypatch")
29+
mp.setattr(NEODySClass, '_request', nonremote_request)
3330
return mp
3431

3532

36-
def test_neodys_query():
37-
res = neodys.core.NEODyS.query_object(
38-
"2018VP1", orbital_element_type='eq', epoch_near_present=0)
39-
assert res['Equinoctial State Vector'] == [1.5881497559198392,
40-
-0.037761493287362, 0.428349632624304, 0.018136658553998,
41-
0.021742631955829, 14.9386830433394]
33+
def test_neodys_query(patch_request):
34+
res = NEODyS.query_object(
35+
object_id="2018VP1", orbital_element_type='eq', epoch_near_present=0)
36+
np.testing.assert_allclose(res['Equinoctial State Vector'],
37+
[1.5881497559198392, -0.037761493287362, 0.428349632624304, 0.018136658553998,
38+
0.021742631955829, 14.9386830433394])
4239
assert res['Mean Julian Date'] == ['58430.299591399', 'TDT']
4340
assert res['Magnitude'] == [30.865, 0.15]
44-
assert res['Covariance Matrix'] == [3.212371896244936e-07,
45-
-1.890888042008199e-08, 1.279370251108077e-07, 4.306149504243656e-09,
46-
5.180213121424896e-09, -7.806384186165599e-06, 1.113155399664521e-09,
47-
-7.5307541846631e-09, -2.534799484876558e-10, -3.049291243256377e-10,
48-
4.595165457505564e-07, 5.095265031422349e-08, 1.714984526308656e-09,
49-
2.063091894997213e-09, -3.109000937067305e-06, 5.772527813183736e-11,
50-
6.944207925151111e-11, -1.04644520025806e-07, 8.353717813321847e-11,
51-
-1.258850849126041e-07, 0.0001897040272481179]
41+
np.testing.assert_allclose(
42+
res['Covariance Matrix'],
43+
[3.212371896244936e-07, -1.890888042008199e-08, 1.279370251108077e-07, 4.306149504243656e-09,
44+
5.180213121424896e-09, -7.806384186165599e-06, 1.113155399664521e-09, -7.5307541846631e-09,
45+
-2.534799484876558e-10, -3.049291243256377e-10, 4.595165457505564e-07, 5.095265031422349e-08,
46+
1.714984526308656e-09, 2.063091894997213e-09, -3.109000937067305e-06, 5.772527813183736e-11,
47+
6.944207925151111e-11, -1.04644520025806e-07, 8.353717813321847e-11, -1.258850849126041e-07,
48+
0.0001897040272481179])

astroquery/neodys/tests/test_neodys_remote.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
import pytest
12

2-
from ... import neodys
3+
from astroquery.neodys import NEODyS
34

45

6+
@pytest.mark.remote_data
57
def test_neodys_query():
68

79
test_object = "2018VP1"
810

9-
res_kep_0 = neodys.core.NEODyS.query_object(
10-
test_object, orbital_element_type="ke", epoch_near_present=0)
11-
res_kep_1 = neodys.core.NEODyS.query_object(
12-
test_object, orbital_element_type="ke", epoch_near_present=1)
13-
res_eq_0 = neodys.core.NEODyS.query_object(
14-
test_object, orbital_element_type="eq", epoch_near_present=0)
15-
res_eq_1 = neodys.core.NEODyS.query_object(
16-
test_object, orbital_element_type="eq", epoch_near_present=1)
11+
res_kep_0 = NEODyS.query_object(test_object, orbital_element_type="ke", epoch_near_present=0)
12+
res_kep_1 = NEODyS.query_object(test_object, orbital_element_type="ke", epoch_near_present=1)
13+
res_eq_0 = NEODyS.query_object(test_object, orbital_element_type="eq", epoch_near_present=0)
14+
res_eq_1 = NEODyS.query_object(test_object, orbital_element_type="eq", epoch_near_present=1)
15+
1716
assert len(res_kep_0['Keplerian State Vector']) == 6
1817
assert len(res_kep_0['Covariance Matrix']) == 21
1918
assert res_kep_0['Mean Julian Date'][0] != res_kep_1['Mean Julian Date'][0]

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ above categories. Those services are here:
401401
jplhorizons/jplhorizons.rst
402402
jplsbdb/jplsbdb.rst
403403
nasa_ads/nasa_ads.rst
404+
neodys/neodys.rst
404405
utils/tap.rst
405406

406407

0 commit comments

Comments
 (0)