Skip to content

Commit 4a06571

Browse files
committed
Make sure that servicex can be called by default
We can now call with a default ctor and not worry about configuration settings. Workign on #111
1 parent 946f0db commit 4a06571

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

servicex/servicex.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ def __init__(self,
9595
status_callback_factory,
9696
)
9797

98-
# Make sure the arguments are reasonable
99-
if backend_type is None and servicex_adaptor is None:
100-
raise ServiceXException('Specify backend_type or servicex_adaptor')
101-
10298
# Get the local settings
10399
config = config_adaptor if config_adaptor is not None \
104100
else ServiceXConfigAdaptor()
@@ -110,7 +106,6 @@ def __init__(self,
110106

111107
if not servicex_adaptor:
112108
# Given servicex adaptor is none, this should be ok. Fixes type checkers
113-
assert backend_type is not None
114109
end_point, email, password = config.get_servicex_adaptor_config(backend_type)
115110
servicex_adaptor = ServiceXAdaptor(end_point, email, password)
116111
self._servicex_adaptor = servicex_adaptor

tests/test_servicex.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ def test_default_ctor(mocker):
4141
config.get_default_returned_datatype.assert_called_with('uproot-ftw')
4242

4343

44-
def test_default_ctor_no_type():
45-
with pytest.raises(ServiceXException) as e:
46-
fe.ServiceXDataset('localds://dude')
44+
def test_default_ctor_no_type(mocker):
45+
'''Test the default ctor. This requires that a .servicex file be present to work,
46+
so we are going to dummy it out.
47+
'''
48+
config = mocker.MagicMock(spec=ServiceXConfigAdaptor)
49+
config.settings = Configuration('servicex', 'servicex')
50+
config.get_servicex_adaptor_config.return_value = ('http://no-way.dude', 'j@yaol.com',
51+
'no_spoon_there_is')
52+
53+
fe.ServiceXDataset('localds://dude', config_adaptor=config)
4754

48-
assert "type" in str(e.value)
55+
config.get_servicex_adaptor_config.assert_called_with(None)
56+
config.get_default_returned_datatype.assert_called_with(None)
4957

5058

5159
@pytest.mark.asyncio

0 commit comments

Comments
 (0)