Skip to content

Commit

Permalink
Scheme was getting dropped when handed to did finder (#20)
Browse files Browse the repository at this point in the history
* fix bug - the DID library was eating the scheme
  • Loading branch information
gordonwatts authored Apr 6, 2022
1 parent 8800f0b commit 13932b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/servicex_did_finder_lib/util_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def unwind_params(ps: Dict[str, List[str]]):
if len(new_query) > 0:
new_query = "?" + new_query

return ParsedDIDInfo(info.path + new_query, get_string, file_count)
return ParsedDIDInfo(info._replace(query="").geturl() + new_query, get_string, file_count)
25 changes: 24 additions & 1 deletion tests/servicex_did_finder_lib/test_communication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
import json
from typing import Any, AsyncGenerator, Dict
from typing import Any, AsyncGenerator, Dict, Optional
from unittest.mock import ANY, MagicMock, patch

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


def test_with_scope(rabbitmq, SXAdaptor):
seen_name: Optional[str] = None

async def my_callback(did_name: str, info: Dict[str, Any]):
nonlocal seen_name
seen_name = did_name
yield {
'paths': ["fork/it/over"],
'adler32': 'no clue',
'file_size': 22323,
'file_events': 0,
}

init_rabbit_mq(my_callback, 'http://myrabbit.com', 'test_queue_name', retries=12,
retry_interval=10)

did = "cms:DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8" \
"/RunIIAutumn18NanoAODv7-Nano02Apr2020_102X_upgrade2018_realistic_v21_ext2-v1/NANOAODSIM"
rabbitmq.send_did_request(did)

assert seen_name == did


def test_failed_file(rabbitmq, SXAdaptor):
'Test a callback that fails before any files are sent'

Expand Down
8 changes: 8 additions & 0 deletions tests/servicex_did_finder_lib/test_util_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def test_plain_uri():
assert r.file_count == -1


def test_scoped_uri():
r = parse_did_uri('scope:forkit')

assert r.did == "scope:forkit"
assert r.get_mode == "all"
assert r.file_count == -1


def test_uri_with_mode_avail():
r = parse_did_uri('forkit?get=available')

Expand Down

0 comments on commit 13932b7

Please sign in to comment.