55from pathlib import Path
66
77import responses
8-
98from api .constants import ARCSECOND_API_URL_DEV
10- from arcsecond import ArcsecondConfig , DatasetUploadContext , DatasetFileUploader , AllSkyCameraImageUploadContext , \
11- AllSkyCameraImageFileUploader
12- from arcsecond .cloud .uploader .constants import Substatus , Status
9+
10+ from arcsecond import (
11+ AllSkyCameraImageFileUploader ,
12+ AllSkyCameraImageUploadContext ,
13+ ArcsecondConfig ,
14+ DatasetFileUploader ,
15+ DatasetUploadContext ,
16+ )
17+ from arcsecond .cloud .uploader .constants import Status , Substatus
1318from arcsecond .options import State
14- from tests .utils import prepare_successful_login , prepare_upload_files , prepare_upload_allskyimage
19+ from tests .utils import (
20+ prepare_successful_login ,
21+ prepare_upload_allskyimage ,
22+ prepare_upload_files ,
23+ )
1524
1625
1726@responses .activate
1827def test_full_upload_process_datafiles ():
1928 dataset_uuid = str (uuid .uuid4 ())
2029 telescope_uuid = str (uuid .uuid4 ())
21- org_subdomain = ' test-portal'
30+ org_subdomain = " test-portal"
2231
2332 prepare_successful_login (org_subdomain )
2433 prepare_upload_files (dataset_uuid , telescope_uuid , org_subdomain )
2534
2635 # file upload
2736 datafile_id = random .randint (1 , 1000 )
2837 responses .post (
29- "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , ' datafiles' ]) + "/" ,
38+ "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , " datafiles" ]) + "/" ,
3039 status = 201 ,
31- json = {"status" : "success" , "id" : datafile_id }
40+ json = {"status" : "success" , "id" : datafile_id },
3241 )
3342 # update metadata
3443 responses .patch (
35- "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , 'datafiles' , str (datafile_id )]) + "/" ,
44+ "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , "datafiles" , str (datafile_id )])
45+ + "/" ,
3646 status = 200 ,
37- json = {"id" : datafile_id }
47+ json = {"id" : datafile_id },
3848 )
3949
40- state = State (is_using_cli = False , verbose = False , api_name = ' cloud' )
50+ state = State (is_using_cli = False , verbose = False , api_name = " cloud" )
4151 config = {
42- ' cloud' : {
43- ' username' : ' dummy' ,
44- ' upload_key' : ' 1234' ,
45- ' api_server' : ARCSECOND_API_URL_DEV
52+ " cloud" : {
53+ " username" : " dummy" ,
54+ " upload_key" : " 1234" ,
55+ " api_server" : ARCSECOND_API_URL_DEV ,
4656 }
4757 }
4858 config = ArcsecondConfig (state , config ) # it will read your config file.
@@ -52,12 +62,12 @@ def test_full_upload_process_datafiles():
5262 input_dataset_uuid_or_name = dataset_uuid ,
5363 input_telescope_uuid = telescope_uuid ,
5464 is_raw_data = True ,
55- org_subdomain = org_subdomain
65+ org_subdomain = org_subdomain ,
5666 )
5767
5868 context .validate () # important step to perform before uploading.
5969 fixtures_dir = Path (__file__ ).parent .parent .parent .parent / "fixtures"
60- fixture_files = list (fixtures_dir .glob (' *.fits' ))
70+ fixture_files = list (fixtures_dir .glob (" *.fits" ))
6171
6272 for fixture_file in fixture_files :
6373 # Create a temporary directory and copy the fixture file there
@@ -67,10 +77,7 @@ def test_full_upload_process_datafiles():
6777
6878 # Use the actual file for uploading
6979 uploader = DatasetFileUploader (
70- context ,
71- str (temp_dir ),
72- str (temp_path ),
73- display_progress = False
80+ context , str (temp_dir ), str (temp_path ), display_progress = False
7481 )
7582
7683 status , substatus , error = uploader .upload_file ()
@@ -82,44 +89,45 @@ def test_full_upload_process_datafiles():
8289@responses .activate
8390def test_full_upload_process_allskyimages ():
8491 camera_uuid = str (uuid .uuid4 ())
85- org_subdomain = ' test-portal'
92+ org_subdomain = " test-portal"
8693
8794 prepare_successful_login (org_subdomain )
8895 prepare_upload_allskyimage (camera_uuid , org_subdomain )
8996
9097 # file upload
9198 image_id = random .randint (1 , 1000 )
9299 responses .post (
93- "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , ' allskycameraimages' ]) + "/" ,
100+ "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , " allskycameraimages" ]) + "/" ,
94101 status = 201 ,
95- json = {"status" : "success" , "id" : image_id }
102+ json = {"status" : "success" , "id" : image_id },
96103 )
97104 # update metadata
98105 responses .patch (
99- "/" .join ([ARCSECOND_API_URL_DEV , org_subdomain , 'allskycameraimages' , str (image_id )]) + "/" ,
106+ "/" .join (
107+ [ARCSECOND_API_URL_DEV , org_subdomain , "allskycameraimages" , str (image_id )]
108+ )
109+ + "/" ,
100110 status = 200 ,
101- json = {"id" : image_id }
111+ json = {"id" : image_id },
102112 )
103113
104- state = State (is_using_cli = False , verbose = False , api_name = ' cloud' )
114+ state = State (is_using_cli = False , verbose = False , api_name = " cloud" )
105115 config = {
106- ' cloud' : {
107- ' username' : ' dummy' ,
108- ' upload_key' : ' 1234' ,
109- ' api_server' : ARCSECOND_API_URL_DEV
116+ " cloud" : {
117+ " username" : " dummy" ,
118+ " upload_key" : " 1234" ,
119+ " api_server" : ARCSECOND_API_URL_DEV ,
110120 }
111121 }
112122 config = ArcsecondConfig (state , config ) # it will read your config file.
113123
114124 context = AllSkyCameraImageUploadContext (
115- config ,
116- input_camera_uuid = camera_uuid ,
117- org_subdomain = org_subdomain
125+ config , input_camera_uuid = camera_uuid , org_subdomain = org_subdomain
118126 )
119127
120128 context .validate () # important step to perform before uploading.
121129 fixtures_dir = Path (__file__ ).parent .parent .parent .parent / "fixtures"
122- fixture_files = list (fixtures_dir .glob (' *.fits' ))
130+ fixture_files = list (fixtures_dir .glob (" *.fits" ))
123131
124132 for fixture_file in fixture_files :
125133 # Create a temporary directory and copy the fixture file there
@@ -129,10 +137,7 @@ def test_full_upload_process_allskyimages():
129137
130138 # Use the actual file for uploading
131139 uploader = AllSkyCameraImageFileUploader (
132- context ,
133- str (temp_dir ),
134- str (temp_path ),
135- display_progress = False
140+ context , str (temp_dir ), str (temp_path ), display_progress = False
136141 )
137142
138143 status , substatus , error = uploader .upload_file ()
0 commit comments