Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
72b9246d
Commit
72b9246d
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
SW-382
: fix tests
parent
a816b998
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MAC/TBB/lib/tbb_freeze.py
+1
-1
1 addition, 1 deletion
MAC/TBB/lib/tbb_freeze.py
SAS/TriggerServices/test/t_trigger_service.py
+18
-8
18 additions, 8 deletions
SAS/TriggerServices/test/t_trigger_service.py
with
19 additions
and
9 deletions
MAC/TBB/lib/tbb_freeze.py
+
1
−
1
View file @
72b9246d
...
...
@@ -62,7 +62,7 @@ def freeze_tbb(stations, dm, timesec, timensec):
# lcuhead to the stations and chain it into the command, so that we are not delayed by lcurun/ssh.
# wait for timestamp, then stop all boards on all stations.
timestamp
=
float
(
"
%
s
.%09d
"
%
(
timesec
,
timensec
))
timestamp
=
float
(
"
%
d
.%09d
"
%
(
timesec
,
timensec
))
if
dm
is
not
None
:
timestamp
+=
0.32
*
dm
...
...
This diff is collapsed.
Click to expand it.
SAS/TriggerServices/test/t_trigger_service.py
+
18
−
8
View file @
72b9246d
...
...
@@ -24,7 +24,7 @@ import unittest
import
os
import
logging
from
lofar.triggerservices.trigger_service
import
TriggerHandler
,
ALERTHandler
from
lofar.triggerservices.trigger_service
import
TriggerHandler
,
ALERTHandler
,
DEFAULT_TBB_PROJECT
import
lofar.triggerservices.trigger_service
as
serv
from
lofar.specificationservices.translation_service
import
SpecificationTranslationHandler
from
lxml
import
etree
...
...
@@ -124,12 +124,22 @@ class TestALERTHandler(unittest.TestCase):
logging
.
info
(
'
Setup test %s
'
%
self
.
_testMethodName
)
def
test_valid_voevent_should_invoke_tbb_dump
(
self
):
with
mock
.
patch
(
'
lofar.triggerservices.trigger_service.momqueryrpc
'
)
as
momrpc
,
\
mock
.
patch
(
'
lofar.mac.tbbservice.client.tbbservice_rpc.TBBRPC.do_tbb_subband_dump
'
)
as
dump
,
\
mock
.
patch
(
'
lofar.triggerservices.voevent_decider.ALERTDecider
'
)
as
sciencecheck
:
momrpc
.
allows_triggers
.
return_value
=
{
'
allows
'
:
True
}
momrpc
.
get_trigger_quota
.
return_value
=
{
'
used_triggers
'
:
4
,
'
allocated_triggers
'
:
5
}
with
mock
.
patch
(
'
lofar.mac.tbbservice.client.tbbservice_rpc.TBBRPC.do_tbb_subband_dump
'
)
as
dump
,
\
mock
.
patch
(
'
lofar.triggerservices.voevent_decider.ALERTDecider
'
)
as
sciencecheck
:
self
.
handler
.
_cache
.
get_project_info
=
mock
.
MagicMock
()
self
.
handler
.
_cache
.
get_project_info
.
return_value
=
{
'
allow_triggers
'
:
True
,
'
num_used_triggers
'
:
4
,
'
num_allowed_triggers
'
:
5
}
self
.
handler
.
_cache
.
get_active_tasks
=
mock
.
MagicMock
()
self
.
handler
.
_cache
.
get_stations
=
mock
.
MagicMock
()
self
.
handler
.
_cache
.
get_stations
.
return_value
=
[
'
CS004C
'
]
test_task
=
mock
.
MagicMock
()
test_task
.
radb_task
=
dict
(
otdb_id
=
123456
)
self
.
handler
.
_cache
.
get_active_tasks
.
return_value
=
[
test_task
]
sciencecheck
.
is_acceptable
.
return_value
=
True
self
.
handler
.
handle_event
(
self
.
voevent_xml
,
self
.
voevent_etree
)
dump
.
assert_called_once
()
...
...
@@ -140,7 +150,7 @@ class TestALERTHandler(unittest.TestCase):
with
self
.
assertRaises
(
Exception
)
as
err
:
self
.
handler
.
handle_event
(
self
.
voevent_xml
,
self
.
voevent_etree
)
self
.
assertTrue
(
'
exceeded
'
in
str
(
err
.
exception
))
self
.
assertTrue
(
'
pre-flight checks!
'
in
str
(
err
.
exception
))
def
test_voevent_not_authorized_should_raise_exception
(
self
):
with
mock
.
patch
(
'
lofar.triggerservices.trigger_service.momqueryrpc
'
)
as
momrpc
:
...
...
@@ -149,7 +159,7 @@ class TestALERTHandler(unittest.TestCase):
with
self
.
assertRaises
(
Exception
)
as
err
:
self
.
handler
.
handle_event
(
self
.
voevent_xml
,
self
.
voevent_etree
)
self
.
assertTrue
(
'
not allowed
'
in
str
(
err
.
exception
))
self
.
assertTrue
(
'
pre-flight checks!
'
in
str
(
err
.
exception
))
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment