Skip to content

Commit

Permalink
Fix class instance mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Nov 26, 2021
1 parent c8c19c6 commit ca4ddc1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions astroquery/esa/jwst/tests/test_jwsttap.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,9 @@ def __check_extracted_files(self, files_expected, files_returned):

def test_query_target(self):
jwst = JwstClass()
simbad = Simbad()
ned = Ned()
vizier = Vizier()
# Testing default parameters
with pytest.raises(ValueError) as err:
jwst.query_target(target_name="M1", target_resolver="")
Expand All @@ -942,13 +945,13 @@ def test_query_target(self):
# Testing no valid coordinates from resolvers
simbad_file = data_path('test_query_by_target_name_simbad_ned_error.vot')
simbad_table = Table.read(simbad_file)
Simbad.query_object = MagicMock(return_value=simbad_table)
simbad.query_object = MagicMock(return_value=simbad_table)
ned_file = data_path('test_query_by_target_name_simbad_ned_error.vot')
ned_table = Table.read(ned_file)
Ned.query_object = MagicMock(return_value=ned_table)
ned.query_object = MagicMock(return_value=ned_table)
vizier_file = data_path('test_query_by_target_name_vizier_error.vot')
vizier_table = Table.read(vizier_file)
Vizier.query_object = MagicMock(return_value=vizier_table)
vizier.query_object = MagicMock(return_value=vizier_table)

coordinate_error = 'coordinate must be either a string or astropy.coordinates'
with pytest.raises(ValueError) as err:
Expand Down Expand Up @@ -980,14 +983,14 @@ def test_query_target(self):
parameters['upload_table_name'] = None
simbad_file = data_path('test_query_by_target_name_simbad.vot')
simbad_table = Table.read(simbad_file)
Simbad.query_object = MagicMock(return_value=simbad_table)
simbad.query_object = MagicMock(return_value=simbad_table)
ned_file = data_path('test_query_by_target_name_ned.vot')
ned_table = Table.read(ned_file)
Ned.query_object = MagicMock(return_value=ned_table)
ned.query_object = MagicMock(return_value=ned_table)
vizier_file = data_path('test_query_by_target_name_vizier.vot')
vizier_table = Table.read(vizier_file)
vizier_table_list = TableList({'1': vizier_table})
Vizier.query_object = MagicMock(return_value=vizier_table_list)
vizier.query_object = MagicMock(return_value=vizier_table_list)

with open(data_path('test_query_by_target_name_simbad_query.txt'), 'r') as file:
parameters['query'] = file.read()
Expand Down

0 comments on commit ca4ddc1

Please sign in to comment.