2
2
import os
3
3
from unittest import TestCase
4
4
5
+ from dotenv import load_dotenv
6
+
5
7
from mdps_ds_lib .ds_client .auth_token .token_abstract import TokenAbstract
6
8
from mdps_ds_lib .ds_client .auth_token .token_factory import TokenFactory
7
9
from mdps_ds_lib .ds_client .ds_client_admin import DsClientAdmin
8
10
from mdps_ds_lib .ds_client .ds_client_user import DsClientUser
9
11
10
12
11
13
class TestDsClientAdmin (TestCase ):
14
+ def setUp (self ) -> None :
15
+ super ().setUp ()
16
+ load_dotenv ()
12
17
def test_01_admin (self ):
13
18
os .environ ['TRUST_ENV' ] = 'TRUE'
14
19
os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
@@ -33,12 +38,6 @@ def test_01_admin(self):
33
38
34
39
def test_query_granules_across_collections (self ):
35
40
os .environ ['TRUST_ENV' ] = 'TRUE'
36
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
37
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
38
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
39
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
40
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
41
-
42
41
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
43
42
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
44
43
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -55,12 +54,6 @@ def test_query_granules_across_collections(self):
55
54
56
55
def test_query_collections (self ):
57
56
os .environ ['TRUST_ENV' ] = 'TRUE'
58
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
59
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
60
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
61
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
62
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
63
-
64
57
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
65
58
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
66
59
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -70,12 +63,6 @@ def test_query_collections(self):
70
63
71
64
def test_query_single_collection (self ):
72
65
os .environ ['TRUST_ENV' ] = 'TRUE'
73
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
74
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
75
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
76
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
77
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
78
-
79
66
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
80
67
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
81
68
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -92,12 +79,6 @@ def test_query_single_collection(self):
92
79
93
80
def test_query_granules (self ):
94
81
os .environ ['TRUST_ENV' ] = 'TRUE'
95
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
96
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
97
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
98
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
99
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
100
-
101
82
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
102
83
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
103
84
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -117,12 +98,6 @@ def test_query_granules(self):
117
98
118
99
def test_query_granules02 (self ):
119
100
os .environ ['TRUST_ENV' ] = 'TRUE'
120
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
121
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
122
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
123
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
124
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
125
-
126
101
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
127
102
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
128
103
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'am-uds-dapa' )
@@ -151,12 +126,6 @@ def test_query_granules02(self):
151
126
152
127
def test_query_custom_properties (self ):
153
128
os .environ ['TRUST_ENV' ] = 'TRUE'
154
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
155
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
156
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
157
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
158
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
159
-
160
129
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
161
130
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
162
131
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'am-uds-dapa' )
@@ -178,12 +147,6 @@ def test_query_custom_properties(self):
178
147
179
148
def test_query_single_granule (self ):
180
149
os .environ ['TRUST_ENV' ] = 'TRUE'
181
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
182
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
183
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
184
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
185
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
186
-
187
150
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
188
151
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
189
152
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'am-uds-dapa' )
@@ -202,12 +165,6 @@ def test_query_single_granule(self):
202
165
203
166
def test_update_admin (self ):
204
167
os .environ ['TRUST_ENV' ] = 'TRUE'
205
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
206
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
207
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
208
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
209
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
210
-
211
168
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
212
169
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
213
170
client = DsClientAdmin (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -225,12 +182,6 @@ def test_update_admin(self):
225
182
226
183
def test_delete_single_granule (self ):
227
184
os .environ ['TRUST_ENV' ] = 'TRUE'
228
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
229
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
230
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
231
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
232
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
233
-
234
185
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
235
186
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
236
187
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' )
@@ -243,21 +194,53 @@ def test_delete_single_granule(self):
243
194
client .tenant_venue = 'DEV'
244
195
client .collection = 'DDD-01'
245
196
client .collection_venue = '001'
246
- client .granule = 'test_file10'
247
197
# urn:nasa:unity:uds_local_test:DEV1:CHRP_16_DAY_REBIN___10:SNDR.SS1330.CHIRP.20230101T0000.m06.g001.L1_J1.std.v02_48.G.200101070318_REBIN
248
198
print (client .delete_single_granule ())
249
199
return
250
200
251
201
def test_query_catalog (self ):
252
202
os .environ ['TRUST_ENV' ] = 'TRUE'
253
- os .environ ['PASSWORD_TYPE' ] = 'PARAM_STORE'
254
- os .environ ['USERNAME' ] = '/unity/uds/user/wphyo/username'
255
- os .environ ['PASSWORD' ] = '/unity/uds/user/wphyo/dwssap'
256
- os .environ ['CLIENT_ID' ] = '71g0c73jl77gsqhtlfg2ht388c'
257
- os .environ ['COGNITO_URL' ] = 'https://cognito-idp.us-west-2.amazonaws.com'
258
-
259
203
os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
260
204
token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
261
205
client = DsClientUser (token_retriever , 'https://d3vc8w9zcq658.cloudfront.net' , 'data-sbx' ) # data-sbx'
262
206
print (json .dumps (client .query_catalog (), indent = 4 ))
263
207
return
208
+
209
+ def test_query_granules01 (self ):
210
+ os .environ ['TRUST_ENV' ] = 'TRUE'
211
+ # https://api.test.mdps.mcp.nasa.gov/am-uds-dapa/collections/URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2/items
212
+ os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
213
+ token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
214
+ client = DsClientUser (token_retriever , 'https://api.test.mdps.mcp.nasa.gov' , 'am-uds-dapa' )
215
+ # client = DsClientAdmin(token_retriever, 'http://localhost:8005', 'data')
216
+
217
+ client .urn = 'URN'
218
+ client .org = 'NASA'
219
+ client .project = 'UNITY'
220
+ client .tenant = 'unity'
221
+ client .tenant_venue = 'test'
222
+ client .collection = 'TRPSDL2ALLCRS1MGLOS'
223
+ client .collection_venue = '2'
224
+ result = client .query_granules (sort_keys = '+properties.datetime,-id' ) # bbox='-114,32.5,-113,33.5'
225
+ print (json .dumps (result , indent = 4 ))
226
+ return
227
+
228
+ def test_archive_one (self ):
229
+ os .environ ['TRUST_ENV' ] = 'TRUE'
230
+ # https://api.test.mdps.mcp.nasa.gov/am-uds-dapa/collections/URN:NASA:UNITY:unity:test:TRPSDL2ALLCRS1MGLOS___2/items
231
+ os .environ ['TOKEN_FACTORY' ] = 'COGNITO'
232
+ token_retriever : TokenAbstract = TokenFactory ().get_instance (os .getenv ('TOKEN_FACTORY' ))
233
+ client = DsClientUser (token_retriever , 'https://api.test.mdps.mcp.nasa.gov' , 'am-uds-dapa' )
234
+ # client = DsClientAdmin(token_retriever, 'http://localhost:8005', 'data')
235
+
236
+ client .urn = 'URN'
237
+ client .org = 'NASA'
238
+ client .project = 'UNITY'
239
+ client .tenant = 'unity'
240
+ client .tenant_venue = 'test'
241
+ client .collection = 'TRPSDL2ALLCRS1MGLOS'
242
+ client .collection_venue = '2'
243
+ client .granule = 'TROPESS_CrIS-JPSS1_L2_Standard_NH3_20250108_MUSES_R1p23_megacity_los_angeles_MGLOS_F2p5_J0'
244
+
245
+ print (client .archive_granule ())
246
+ return
0 commit comments