Skip to content

Commit 13932b7

Browse files
authored
Scheme was getting dropped when handed to did finder (#20)
* fix bug - the DID library was eating the scheme
1 parent 8800f0b commit 13932b7

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/servicex_did_finder_lib/util_uri.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ def unwind_params(ps: Dict[str, List[str]]):
5757
if len(new_query) > 0:
5858
new_query = "?" + new_query
5959

60-
return ParsedDIDInfo(info.path + new_query, get_string, file_count)
60+
return ParsedDIDInfo(info._replace(query="").geturl() + new_query, get_string, file_count)

tests/servicex_did_finder_lib/test_communication.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22
import json
3-
from typing import Any, AsyncGenerator, Dict
3+
from typing import Any, AsyncGenerator, Dict, Optional
44
from unittest.mock import ANY, MagicMock, patch
55

66
import pika
@@ -154,6 +154,29 @@ async def my_callback(did_name: str, info: Dict[str, Any]):
154154
SXAdaptor.put_fileset_complete.assert_called_once()
155155

156156

157+
def test_with_scope(rabbitmq, SXAdaptor):
158+
seen_name: Optional[str] = None
159+
160+
async def my_callback(did_name: str, info: Dict[str, Any]):
161+
nonlocal seen_name
162+
seen_name = did_name
163+
yield {
164+
'paths': ["fork/it/over"],
165+
'adler32': 'no clue',
166+
'file_size': 22323,
167+
'file_events': 0,
168+
}
169+
170+
init_rabbit_mq(my_callback, 'http://myrabbit.com', 'test_queue_name', retries=12,
171+
retry_interval=10)
172+
173+
did = "cms:DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8" \
174+
"/RunIIAutumn18NanoAODv7-Nano02Apr2020_102X_upgrade2018_realistic_v21_ext2-v1/NANOAODSIM"
175+
rabbitmq.send_did_request(did)
176+
177+
assert seen_name == did
178+
179+
157180
def test_failed_file(rabbitmq, SXAdaptor):
158181
'Test a callback that fails before any files are sent'
159182

tests/servicex_did_finder_lib/test_util_uri.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ def test_plain_uri():
1010
assert r.file_count == -1
1111

1212

13+
def test_scoped_uri():
14+
r = parse_did_uri('scope:forkit')
15+
16+
assert r.did == "scope:forkit"
17+
assert r.get_mode == "all"
18+
assert r.file_count == -1
19+
20+
1321
def test_uri_with_mode_avail():
1422
r = parse_did_uri('forkit?get=available')
1523

0 commit comments

Comments
 (0)