Skip to content

Commit 5506149

Browse files
committed
add requets test for igs download
1 parent 3944359 commit 5506149

1 file changed

Lines changed: 43 additions & 2 deletions

File tree

tests/parsers/test_ephemeris.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import os
99
import ftplib
10+
import requests
1011
from datetime import datetime, timezone
1112

1213
import pytest
@@ -247,8 +248,48 @@ def test_download_ephem(ephem_download_path, fileinfo):
247248
dest_filepath = os.path.join(ephem_man.data_directory, 'nasa', filename)
248249

249250
# download the ephemeris file
250-
ephem_man.retrieve_file(url, directory, filename,
251-
dest_filepath)
251+
try:
252+
ephem_man.retrieve_file(url, directory, filename,
253+
dest_filepath)
254+
except ftplib.error_perm as ftplib_exception:
255+
print(ftplib_exception)
256+
257+
remove_download_eph(ephem_download_path)
258+
259+
@pytest.mark.parametrize('fileinfo',
260+
[
261+
{'filepath': 'IGS/BRDC/2023/099/BRDC00WRD_S_20230990000_01D_MN.rnx.gz',
262+
'url': 'http://igs.bkg.bund.de/root_ftp/'},
263+
])
264+
def test_request_igs(ephem_download_path, fileinfo):
265+
"""Test requests download for igs files.
266+
267+
The reason for this test is that Github workflow actions seem to
268+
block international IPs and so won't properly bind to the igs IP.
269+
270+
Parameters
271+
----------
272+
ephem_download_path : string
273+
Location where ephemeris files are stored/to be downloaded to.
274+
fileinfo : dict
275+
Filenames for ephemeris with ftp server and constellation details
276+
277+
"""
278+
279+
remove_download_eph(ephem_download_path)
280+
os.makedirs(ephem_download_path)
281+
282+
ephem_man = EphemerisManager(ephem_download_path, verbose=True)
283+
284+
filepath = fileinfo['filepath']
285+
filename = os.path.split(filepath)[1]
286+
dest_filepath = os.path.join(ephem_man.data_directory, 'igs', filename)
287+
288+
requests_url = fileinfo['url'] + fileinfo['filepath']
289+
290+
response = requests.get(requests_url, timeout=5)
291+
with open(dest_filepath,'wb') as file:
292+
file.write(response.content)
252293

253294
remove_download_eph(ephem_download_path)
254295

0 commit comments

Comments
 (0)