Skip to content

Commit cdad05f

Browse files
committed
Allow missing type in config file when looking for backend type
We missed a pick-up - and in fact the default config file that comes with this caused the bomb! If there was a type missing, when you looked for the backend type, you'd get a bomb! Fixes #115
1 parent 5bd2753 commit cdad05f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

servicex/servicex_config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ def get_backend_info(self, backend_type: str, key: str) -> Optional[str]:
7171
def find_in_list(c, key) -> Optional[str]:
7272
if c.exists():
7373
for ep in c:
74-
if ep['type'].as_str() == backend_type:
75-
if key in ep:
76-
return ep[key].as_str_expanded()
74+
if ep['type'].exists():
75+
if ep['type'].as_str() == backend_type:
76+
if key in ep:
77+
return ep[key].as_str_expanded()
7778
return None
7879

7980
a = find_in_list(self._settings['api_endpoints'], key)

tests/test_servicex_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ def test_returned_datatype_from_endpoint():
5050
assert x.get_default_returned_datatype('forkit') == 'spoons'
5151

5252

53+
def test_returned_datatype_no_type_endpoint():
54+
c = ConfigSettings('servicex', 'servicex')
55+
c.clear()
56+
c['backend_types'] = [{'type': 'forkit', 'return_data': 'spoon'}]
57+
c['api_endpoints'] = [{'endpoint': 'http://localhost:5000'}]
58+
x = ServiceXConfigAdaptor(c)
59+
assert x.get_default_returned_datatype('forkit') == 'spoon'
60+
5361
def test_defalt_config_has_default_return_datatype():
5462
'Test default settings - default_returned_datatype'
5563
c = ConfigSettings('servicex', 'servicex')

0 commit comments

Comments
 (0)