Skip to content

Commit 636be6a

Browse files
committed
Recover all unit tests
They are either moved to new files, or made to be working after commits from master were pulled in.
1 parent 368d441 commit 636be6a

File tree

5 files changed

+35
-57
lines changed

5 files changed

+35
-57
lines changed

servicex/servicex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def __init__(self,
107107

108108
if not servicex_adaptor:
109109
# Given servicex adaptor is none, this should be ok. Fixes type checkers
110-
end_point, email, password = config.get_servicex_adaptor_config(backend_type)
111-
servicex_adaptor = ServiceXAdaptor(end_point, email, password)
110+
end_point, token = config.get_servicex_adaptor_config(backend_type)
111+
servicex_adaptor = ServiceXAdaptor(end_point, token)
112112
self._servicex_adaptor = servicex_adaptor
113113

114114
if not minio_adaptor:

servicex/servicex_adaptor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,3 @@ async def trap_servicex_failures(stream: AsyncIterator[TransformTuple]) \
239239
f'processed: {processed}).')
240240

241241
yield p
242-

servicex/servicex_config.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def find_in_list(c, key) -> Optional[str]:
8282
return a
8383

8484
def get_servicex_adaptor_config(self, backend_type: Optional[str] = None) -> \
85-
Tuple[str, Optional[str], Optional[str]]:
85+
Tuple[str, Optional[str]]:
8686
'''Return the servicex (endpoint, username, email) from a given backend configuration.
8787
8888
Args:
@@ -97,14 +97,12 @@ def get_servicex_adaptor_config(self, backend_type: Optional[str] = None) -> \
9797
# It is an error if this is not specified somewhere.
9898
endpoints = self._settings['api_endpoints']
9999

100-
def extract_info(ep) -> Tuple[str, Optional[str], Optional[str]]:
100+
def extract_info(ep) -> Tuple[str, Optional[str]]:
101101
endpoint = ep['endpoint'].as_str_expanded()
102-
email = ep['email'].as_str_expanded() if 'email' in ep else None
103-
password = ep['password'].as_str_expanded() if 'password' in ep \
104-
else None
102+
token = ep['token'].as_str_expanded() if 'token' in ep else None
105103

106104
# We can default these to "None"
107-
return (endpoint, email, password) # type: ignore
105+
return (endpoint, token) # type: ignore
108106

109107
# If we have a good name, look for exact match
110108
if backend_type is not None:

tests/test_servicex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_default_ctor(mocker):
3232
'''
3333
config = mocker.MagicMock(spec=ServiceXConfigAdaptor)
3434
config.settings = Configuration('servicex', 'servicex')
35-
config.get_servicex_adaptor_config.return_value = ('http://no-way.dude', 'j@yaol.com',
35+
config.get_servicex_adaptor_config.return_value = ('http://no-way.dude',
3636
'no_spoon_there_is')
3737

3838
fe.ServiceXDataset('localds://dude', "uproot-ftw", config_adaptor=config)
@@ -47,7 +47,7 @@ def test_default_ctor_no_type(mocker):
4747
'''
4848
config = mocker.MagicMock(spec=ServiceXConfigAdaptor)
4949
config.settings = Configuration('servicex', 'servicex')
50-
config.get_servicex_adaptor_config.return_value = ('http://no-way.dude', 'j@yaol.com',
50+
config.get_servicex_adaptor_config.return_value = ('http://no-way.dude',
5151
'no_spoon_there_is')
5252

5353
fe.ServiceXDataset('localds://dude', config_adaptor=config)

tests/test_servicex_config.py

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,14 @@ def test_sx_adaptor_settings(caplog):
8383
{
8484
'type': 'my-type',
8585
'endpoint': 'http://my-left-foot.com:5000',
86-
'email': 'thegoodplace@example.com',
87-
'password': 'forkingshirtballs',
86+
'token': 'forkingshirtballs.thegoodplace.bortles'
8887
}
8988
]
9089
x = ServiceXConfigAdaptor(c)
91-
endpoint, email, password = x.get_servicex_adaptor_config('my-type')
90+
endpoint, token = x.get_servicex_adaptor_config('my-type')
9291

9392
assert endpoint == 'http://my-left-foot.com:5000'
94-
assert email == 'thegoodplace@example.com'
95-
assert password == 'forkingshirtballs'
93+
assert token == 'forkingshirtballs.thegoodplace.bortles'
9694

9795
assert len(caplog.record_tuples) == 0
9896

@@ -106,16 +104,14 @@ def test_sx_adaptor_settings_no_backend_name_requested(caplog):
106104
{
107105
'type': 'my-type',
108106
'endpoint': 'http://my-left-foot.com:5000',
109-
'email': 'thegoodplace@example.com',
110-
'password': 'forkingshirtballs',
107+
'token': 'forkingshirtballs.thegoodplace.bortles'
111108
}
112109
]
113110
x = ServiceXConfigAdaptor(c)
114-
endpoint, email, password = x.get_servicex_adaptor_config()
111+
endpoint, token = x.get_servicex_adaptor_config()
115112

116113
assert endpoint == 'http://my-left-foot.com:5000'
117-
assert email == 'thegoodplace@example.com'
118-
assert password == 'forkingshirtballs'
114+
assert token == 'forkingshirtballs.thegoodplace.bortles'
119115

120116
assert caplog.record_tuples[0][2] == "No backend type requested, " \
121117
"using http://my-left-foot.com:5000 - please be " \
@@ -131,16 +127,14 @@ def test_sx_adaptor_settings_no_backend_name_requested_or_listed(caplog):
131127
c['api_endpoints'] = [
132128
{
133129
'endpoint': 'http://my-left-foot.com:5000',
134-
'email': 'thegoodplace@example.com',
135-
'password': 'forkingshirtballs',
130+
'token': 'forkingshirtballs.thegoodplace.bortles'
136131
}
137132
]
138133
x = ServiceXConfigAdaptor(c)
139-
endpoint, email, password = x.get_servicex_adaptor_config()
134+
endpoint, token = x.get_servicex_adaptor_config()
140135

141136
assert endpoint == 'http://my-left-foot.com:5000'
142-
assert email == 'thegoodplace@example.com'
143-
assert password == 'forkingshirtballs'
137+
assert token == 'forkingshirtballs.thegoodplace.bortles'
144138

145139
assert caplog.record_tuples[0][2] == "No backend type requested, " \
146140
"using http://my-left-foot.com:5000 - please be " \
@@ -156,16 +150,14 @@ def test_sx_adaptor_settings_backend_name_requested_with_unlabeled_type(caplog):
156150
c['api_endpoints'] = [
157151
{
158152
'endpoint': 'http://my-left-foot.com:5000',
159-
'email': 'thegoodplace@example.com',
160-
'password': 'forkingshirtballs',
153+
'token': 'forkingshirtballs.thegoodplace.bortles'
161154
}
162155
]
163156
x = ServiceXConfigAdaptor(c)
164-
endpoint, email, password = x.get_servicex_adaptor_config('xaod')
157+
endpoint, token = x.get_servicex_adaptor_config('xaod')
165158

166159
assert endpoint == 'http://my-left-foot.com:5000'
167-
assert email == 'thegoodplace@example.com'
168-
assert password == 'forkingshirtballs'
160+
assert token == 'forkingshirtballs.thegoodplace.bortles'
169161

170162
assert caplog.record_tuples[0][2] == "No 'xaod' backend type found, " \
171163
"using http://my-left-foot.com:5000 - please add to " \
@@ -180,22 +172,19 @@ def test_sx_adaptor_settings_backend_name_requested_after_labeled_type(caplog):
180172
c['api_endpoints'] = [
181173
{
182174
'endpoint': 'http://my-left-foot.com:5000',
183-
'email': 'thegoodplace@example.com',
184-
'password': 'forkingshirtballs',
175+
'token': 'forkingshirtballs.thegoodplace.bortles'
185176
},
186177
{
187178
'type': 'xaod',
188179
'endpoint': 'http://my-left-foot.com:5001',
189-
'email': 'thegoodplace1@example.com',
190-
'password': 'forkingshirtballs1',
180+
'token': 'forkingshirtballs.thegoodplace.bortles1'
191181
}
192182
]
193183
x = ServiceXConfigAdaptor(c)
194-
endpoint, email, password = x.get_servicex_adaptor_config('xaod')
184+
endpoint, token = x.get_servicex_adaptor_config('xaod')
195185

196186
assert endpoint == 'http://my-left-foot.com:5001'
197-
assert email == 'thegoodplace1@example.com'
198-
assert password == 'forkingshirtballs1'
187+
assert token == 'forkingshirtballs.thegoodplace.bortles1'
199188

200189
assert len(caplog.record_tuples) == 0
201190

@@ -209,21 +198,18 @@ def test_sx_adaptor_settings_backend_name_unlabeled_type():
209198
{
210199
'type': 'xaod',
211200
'endpoint': 'http://my-left-foot.com:5000',
212-
'email': 'thegoodplace@example.com',
213-
'password': 'forkingshirtballs',
201+
'token': 'forkingshirtballs.thegoodplace.bortles'
214202
},
215203
{
216204
'endpoint': 'http://my-left-foot.com:5001',
217-
'email': 'thegoodplace1@example.com',
218-
'password': 'forkingshirtballs1',
205+
'token': 'forkingshirtballs.thegoodplace.bortles1'
219206
}
220207
]
221208
x = ServiceXConfigAdaptor(c)
222-
endpoint, email, password = x.get_servicex_adaptor_config()
209+
endpoint, token = x.get_servicex_adaptor_config()
223210

224211
assert endpoint == 'http://my-left-foot.com:5001'
225-
assert email == 'thegoodplace1@example.com'
226-
assert password == 'forkingshirtballs1'
212+
assert token == 'forkingshirtballs.thegoodplace.bortles1'
227213

228214

229215
def test_sx_adaptor_settings_wrong_type():
@@ -234,8 +220,7 @@ def test_sx_adaptor_settings_wrong_type():
234220
{
235221
'type': 'my-type',
236222
'endpoint': 'http://my-left-foot.com:5000',
237-
'email': 'thegoodplace@example.com',
238-
'password': 'forkingshirtballs',
223+
'token': 'forkingshirtballs.thegoodplace.bortles'
239224
}
240225
]
241226

@@ -255,23 +240,20 @@ def test_sx_adaptor_settings_env():
255240
{
256241
'type': '${SXTYPE}',
257242
'endpoint': '${ENDPOINT}:5000',
258-
'email': '${SXUSER}',
259-
'password': '${SXPASS}',
243+
'token': '${SXTOKEN}',
260244
}
261245
]
262246

263247
from os import environ
264248
environ['ENDPOINT'] = 'http://tachi.com'
265-
environ['SXUSER'] = 'Holden'
266-
environ['SXPASS'] = 'protomolecule'
267249
environ['SXTYPE'] = 'mcrn'
250+
environ['SXTOKEN'] = 'protomolecule'
268251

269252
x = ServiceXConfigAdaptor(c)
270-
endpoint, email, password = x.get_servicex_adaptor_config('mcrn')
253+
endpoint, token = x.get_servicex_adaptor_config('mcrn')
271254

272255
assert endpoint == 'http://tachi.com:5000'
273-
assert email == 'Holden'
274-
assert password == 'protomolecule'
256+
assert token == 'protomolecule'
275257

276258

277259
def test_default_config_endpoint():
@@ -280,10 +262,9 @@ def test_default_config_endpoint():
280262
c._add_default_source()
281263
x = ServiceXConfigAdaptor(c)
282264

283-
end_point, email, password = x.get_servicex_adaptor_config()
265+
end_point, token = x.get_servicex_adaptor_config()
284266
assert end_point == 'http://localhost:5000'
285-
assert email is None
286-
assert password is None
267+
assert token is None
287268

288269

289270
def test_sx_adaptor_nothing():

0 commit comments

Comments
 (0)