Skip to content

Commit f64e54e

Browse files
committed
this commit includes debug work: for some reason, the warning I'm
expecting to be raised isn't being raised. I could use help here, but now it's telecon time (squash this commit away later)
1 parent 4fc681b commit f64e54e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

astroquery/alma/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ def download_files(self, files, savedir=None, cache=True,
750750

751751
if verify_only:
752752
existing_file_length = os.stat(filename).st_size
753+
print(f"{filename}: {existing_file_length}")
753754
if 'content-length' in check_filename.headers:
754755
length = int(check_filename.headers['content-length'])
755756
if length == 0:
@@ -760,8 +761,11 @@ def download_files(self, files, savedir=None, cache=True,
760761
log.info(f"Found cached file {filename} with size {existing_file_length} < expected "
761762
f"size {length}. The download should be continued.")
762763
elif existing_file_length > length:
764+
print("Issuing a warning")
763765
warnings.warn(f"Found cached file {filename} with size {existing_file_length} > expected "
764766
f"size {length}. The download is likely corrupted.")
767+
else:
768+
raise ValueError("It should not be possible to reach this state.")
765769
else:
766770
warnings.warn(f"Could not verify {url} because it has no 'content-length'")
767771

astroquery/alma/tests/test_alma_remote.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,15 @@ def test_verify_html_file(alma, caplog):
686686
with open(local_filepath, 'ab') as fh:
687687
fh.write(b"Extra Text")
688688

689+
print("Trying the failed version now")
689690
caplog.clear()
690-
with warnings.catch_warnings() as ww:
691+
with warnings.catch_warnings(record=True) as ww:
691692
result = alma.download_files(['https://almascience.nao.ac.jp/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'], verify_only=True)
692693
assert result
693694
length = 66336
694695
existing_file_length = length + 10
696+
print(f"WARNING: {str(ww)}")
697+
print(f"caplog: {caplog.text}")
695698
assert f"Found cached file {local_filepath} with size {existing_file_length} > expected size {length}. The download is likely corrupted." in str(ww)
696699

697700
# manipulate the file: make it small

0 commit comments

Comments
 (0)