Newer
Older
import unittest
import os
from csst_dfs_client import download_file, read_file
class CommonTestCase(unittest.TestCase):
def setUp(self):
pass
def test_download_level0_file(self):
bytes_data = download_file(file_path= "L0/MSC/SCI/60470/10109100157991/MS/CSST_MSC_MS_SCI_20240609181116_20240609181347_10109100157991_27_L0_V01.fits")
# save the downloaded file to a local directory
tmp_file_dir = os.environ.get("UNIT_TEST_DATA_ROOT", "/tmp")
tmp_file_path = os.path.join(tmp_file_dir, "test_downloaded_file.fits")
if os.path.exists(tmp_file_path):
os.remove(tmp_file_path)
def test_read_file(self):
bytes_io = read_file(file_path= "L0/MSC/SCI/60470/10109100157991/MS/CSST_MSC_MS_SCI_20240609181116_20240609181347_10109100157991_27_L0_V01.fits")
# save the downloaded file to a local directory
tmp_file_dir = os.environ.get("UNIT_TEST_DATA_ROOT", "/tmp")
tmp_file_path = os.path.join(tmp_file_dir, "test_downloaded_file.fits")
if os.path.exists(tmp_file_path):
os.remove(tmp_file_path)
with open(tmp_file_path, "wb") as f:
f.write(bytes_io.getvalue())
assert os.path.exists(tmp_file_path)
os.remove(tmp_file_path)