Skip to content

Commit 1aad0a7

Browse files
committed
Fix esa.hsa remote tests
The `esa.hsa` remote tests attempted to compare sorted lists of actual checksums with the expected sorted lists, but the sorting was done using `list.sort()` in the `assert`-statement. `list.sort()` sorts the list in-place and its return value is `None`, so the tests were actually checking `None == None`. Furthermore, the checksums obtained in the tests are not reliably reproducible, so now the tests check the endings of filenames contained in the fetched tar-archives instead.
1 parent a4716fd commit 1aad0a7

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

astroquery/esa/hsa/tests/test_hsa_remote.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77

88
from ..core import HSAClass
99

10-
spire_chksum = [10233, 10762, 9019, 10869, 3944, 11328, 3921, 10999, 10959,
11-
11342, 10974, 3944, 11335, 11323, 11078, 11321, 11089, 11314, 11108, 6281]
1210

13-
pacs_chksum = [10208, 10755, 8917, 10028, 3924, 3935, 6291]
11+
12+
PACS_ENDINGS = ["571.xml", "571.jpg", "214.fits.gz", "008.fits.gz",
13+
"674.fits.gz", "350.fits.gz", "README.pdf"]
14+
SPIRE_ENDINGS = ["898.xml", "898.jpg", "141.fits.gz", "045.fits.gz", "952.fits.gz",
15+
"974.fits.gz", "715.fits.gz", "547.fits.gz", "770.fits.gz",
16+
"856.fits.gz", "148.fits.gz", "025.fits.gz", "538.fits.gz",
17+
"070.fits.gz", "434.fits.gz", "637.fits.gz", "835.fits.gz",
18+
"372.fits.gz","248.fits.gz", "README.pdf"]
1419

1520

1621
@pytest.mark.remote_data
@@ -42,8 +47,10 @@ def test_download_data_observation_pacs(self, tmp_path):
4247
assert Path(res) == expected_res
4348
assert Path(res).is_file()
4449
with tarfile.open(res) as tar:
45-
chksum = [m.chksum for m in tar.getmembers()]
46-
assert chksum.sort() == pacs_chksum.sort()
50+
names = tar.getnames()
51+
assert len(names) == len(PACS_ENDINGS)
52+
for name, ending in zip(names, PACS_ENDINGS):
53+
assert name.endswith(ending)
4754

4855
def test_download_data_observation_pacs_filename(self, tmp_path):
4956
obs_id = "1342191813"
@@ -63,8 +70,10 @@ def test_download_data_observation_pacs_filename(self, tmp_path):
6370
assert Path(res) == expected_res
6471
assert Path(res).is_file()
6572
with tarfile.open(res) as tar:
66-
chksum = [m.chksum for m in tar.getmembers()]
67-
assert chksum.sort() == pacs_chksum.sort()
73+
names = tar.getnames()
74+
assert len(names) == len(PACS_ENDINGS)
75+
for name, ending in zip(names, PACS_ENDINGS):
76+
assert name.endswith(ending)
6877

6978
def test_download_data_observation_pacs_compressed(self, tmp_path):
7079
obs_id = "1342191813"
@@ -83,8 +92,10 @@ def test_download_data_observation_pacs_compressed(self, tmp_path):
8392
assert Path(res) == expected_res
8493
assert Path(res).is_file()
8594
with tarfile.open(res) as tar:
86-
chksum = [m.chksum for m in tar.getmembers()]
87-
assert chksum.sort() == pacs_chksum.sort()
95+
names = tar.getnames()
96+
assert len(names) == len(PACS_ENDINGS)
97+
for name, ending in zip(names, PACS_ENDINGS):
98+
assert name.endswith(ending)
8899

89100
def test_download_data_observation_spire(self, tmp_path):
90101
obs_id = "1342191188"
@@ -102,8 +113,10 @@ def test_download_data_observation_spire(self, tmp_path):
102113
assert Path(res) == expected_res
103114
assert Path(res).is_file()
104115
with tarfile.open(res) as tar:
105-
chksum = [m.chksum for m in tar.getmembers()]
106-
assert chksum.sort() == spire_chksum.sort()
116+
names = tar.getnames()
117+
assert len(names) == len(SPIRE_ENDINGS)
118+
for name, ending in zip(names, SPIRE_ENDINGS):
119+
assert name.endswith(ending)
107120

108121
def test_download_data_postcard_pacs(self, tmp_path):
109122
obs_id = "1342191813"
@@ -152,8 +165,10 @@ def test_get_observation(self, tmp_path):
152165
assert Path(res) == expected_res
153166
assert Path(res).is_file()
154167
with tarfile.open(res) as tar:
155-
chksum = [m.chksum for m in tar.getmembers()]
156-
assert chksum.sort() == pacs_chksum.sort()
168+
names = tar.getnames()
169+
assert len(names) == len(PACS_ENDINGS)
170+
for name, ending in zip(names, PACS_ENDINGS):
171+
assert name.endswith(ending)
157172

158173
def test_get_postcard(self, tmp_path):
159174
obs_id = "1342191813"

0 commit comments

Comments
 (0)