Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit 2ea691b8 authored by Alexander Pace's avatar Alexander Pace

update client tests

parent d7172df2
...@@ -1262,7 +1262,8 @@ class GraceDb(GsiRest): ...@@ -1262,7 +1262,8 @@ class GraceDb(GsiRest):
return self.post(uri, body=request_body) return self.post(uri, body=request_body)
def updateSuperevent(self, superevent_id, t_start=None, t_0=None, def updateSuperevent(self, superevent_id, t_start=None, t_0=None,
t_end=None, preferred_event=None): t_end=None, preferred_event=None, em_type=None,
coinc_far=None):
"""Update a superevent's parameters. """Update a superevent's parameters.
The same permission restrictions apply as for The same permission restrictions apply as for
...@@ -1283,6 +1284,12 @@ class GraceDb(GsiRest): ...@@ -1283,6 +1284,12 @@ class GraceDb(GsiRest):
superevent (``'production'``, ``'test'``, ``'mdc'``) and must superevent (``'production'``, ``'test'``, ``'mdc'``) and must
either already be a part of this superevent, or not be in a either already be a part of this superevent, or not be in a
superevent at all. superevent at all.
em_type (:obj:`str`, optional): name of coincident EM search
for "preferred" EM coincident event. Defined by analyst or
pipeline (e.g., RAVEN). Default is null for new superevents.
coinc_far (:obj:`float`, optional): new value for coincident FAR
with preferred EM coincident event. Defined by analyst or
pipeline (e.g., RAVEN). Default is null for new superevents.
Returns: Returns:
:class:`httplib.HTTPResponse` :class:`httplib.HTTPResponse`
...@@ -1299,9 +1306,10 @@ class GraceDb(GsiRest): ...@@ -1299,9 +1306,10 @@ class GraceDb(GsiRest):
200 200
""" # noqa: W605 """ # noqa: W605
# Make sure that at least one parameter is provided # Make sure that at least one parameter is provided
if not (t_start or t_0 or t_end or preferred_event): if not (t_start or t_0 or t_end or preferred_event or
raise ValueError('Provide at least one of t_start, t_0, t_end, or ' em_type or coinc_far):
'preferred_event') raise ValueError('Provide at least one of t_start, t_0, t_end, '
'preferred_event, em_type, or coinc_far')
request_body = {} request_body = {}
if t_start is not None: if t_start is not None:
...@@ -1312,6 +1320,10 @@ class GraceDb(GsiRest): ...@@ -1312,6 +1320,10 @@ class GraceDb(GsiRest):
request_body['t_end'] = t_end request_body['t_end'] = t_end
if preferred_event is not None: if preferred_event is not None:
request_body['preferred_event'] = preferred_event request_body['preferred_event'] = preferred_event
if em_type is not None:
request_body['em_type'] = em_type
if coinc_far is not None:
request_body['coinc_far'] = coinc_far
template = self.templates['superevent-detail-template'] template = self.templates['superevent-detail-template']
uri = template.format(superevent_id=superevent_id) uri = template.format(superevent_id=superevent_id)
return self.patch(uri, body=request_body) return self.patch(uri, body=request_body)
......
...@@ -329,7 +329,7 @@ def test_creation_args( ...@@ -329,7 +329,7 @@ def test_creation_args(
def test_update_no_args(safe_client): def test_update_no_args(safe_client):
err_msg = 'Provide at least one of t_start, t_0, t_end, or preferred_event' err_msg = 'Provide at least one of t_start, t_0, t_end, preferred_event, em_type, or coinc_far'
with pytest.raises(ValueError, match=err_msg): with pytest.raises(ValueError, match=err_msg):
safe_client.updateSuperevent('S181224a') safe_client.updateSuperevent('S181224a')
...@@ -341,7 +341,10 @@ def test_update_no_args(safe_client): ...@@ -341,7 +341,10 @@ def test_update_no_args(safe_client):
{'t_0': 2}, {'t_0': 2},
{'t_end': 3}, {'t_end': 3},
{'preferred_event': 'G0001'}, {'preferred_event': 'G0001'},
{'t_start': 1, 't_0': 2, 't_end': 3, 'preferred_event': 'G0001'}, {'em_type': 'EM_TEST'},
{'coinc_far': '4'},
{'t_start': 1, 't_0': 2, 't_end': 3, 'preferred_event': 'G0001',
'em_type': 'EM_TEST', 'coinc_far': '4'},
] ]
) )
def test_update_args(safe_client, update_kwargs): def test_update_args(safe_client, update_kwargs):
......
...@@ -119,7 +119,7 @@ def test_creation_args( ...@@ -119,7 +119,7 @@ def test_creation_args(
def test_update_no_args(safe_client): def test_update_no_args(safe_client):
err_msg = 'Provide at least one of t_start, t_0, t_end, or preferred_event' err_msg = 'Provide at least one of t_start, t_0, t_end, preferred_event, em_type, or coinc_far'
with pytest.raises(ValueError, match=err_msg): with pytest.raises(ValueError, match=err_msg):
safe_client.updateSuperevent('S181224a') safe_client.updateSuperevent('S181224a')
...@@ -131,7 +131,10 @@ def test_update_no_args(safe_client): ...@@ -131,7 +131,10 @@ def test_update_no_args(safe_client):
{'t_0': 2}, {'t_0': 2},
{'t_end': 3}, {'t_end': 3},
{'preferred_event': 'G0001'}, {'preferred_event': 'G0001'},
{'t_start': 1, 't_0': 2, 't_end': 3, 'preferred_event': 'G0001'}, {'em_type': 'EM_TEST'},
{'coinc_far': '4'},
{'t_start': 1, 't_0': 2, 't_end': 3, 'preferred_event': 'G0001',
'em_type': 'EM_TEST', 'coinc_far': '4'},
] ]
) )
def test_update_args(safe_client, update_kwargs): def test_update_args(safe_client, update_kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment