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
b2d3d3ff
Commit
b2d3d3ff
authored
4 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-417
: Refactoring
parent
d7710f6e
No related branches found
Branches containing commit
No related tags found
1 merge request
!282
Resolve TMSS-417
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/services/websocket/test/t_websocket_service.py
+18
-26
18 additions, 26 deletions
SAS/TMSS/services/websocket/test/t_websocket_service.py
with
18 additions
and
26 deletions
SAS/TMSS/services/websocket/test/t_websocket_service.py
+
18
−
26
View file @
b2d3d3ff
...
...
@@ -29,14 +29,13 @@ from lofar.sas.tmss.test.test_utils import TMSSTestEnvironment
from
lofar.messaging.messagebus
import
TemporaryExchange
,
BusListenerJanitor
from
lofar.sas.tmss.services.websocket_service
import
create_service
from
lofar.common.test_utils
import
integration_test
from
time
import
sleep
from
datetime
import
datetime
,
timedelta
from
collections
import
deque
from
json
import
loads
as
JSONLoads
from
threading
import
Thread
,
Event
import
websocket
@integration_test
class
TestSubtaskSchedulingService
(
unittest
.
TestCase
):
'''
...
...
@@ -107,36 +106,29 @@ class TestSubtaskSchedulingService(unittest.TestCase):
self
.
start_ws_client
()
# Start ws client
def
test_object
(
json_test
,
obj_type
,
action
):
# Check if the correct/expected json_blobs arrive in the ws client
# Wait for incoming ws message
if
not
self
.
sync_event
.
wait
(
timeout
=
5
):
raise
TimeoutError
()
self
.
sync_event
.
clear
()
# Assert json_blobs
json_blob
=
{
'
id
'
:
json_test
[
'
id
'
],
'
object_type
'
:
obj_type
,
'
action
'
:
action
,
'
object
'
:
json_test
}
self
.
assertEqual
(
json_blob
,
self
.
msg_queue
.
popleft
())
# TODO: Add enums for obj_type and action like in ws service
# Test scheduling_unit_draft create
json_schedulingset
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
SchedulingSet
(),
url_postfix
=
'
/scheduling_set
'
)
json_schedulingunitdraft
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
SchedulingUnitDraft
(
scheduling_set_url
=
json_schedulingset
[
'
url
'
]),
url_postfix
=
'
/scheduling_unit_draft
'
)
if
not
self
.
sync_event
.
wait
(
timeout
=
5
):
raise
TimeoutError
()
self
.
sync_event
.
clear
()
json_blob
=
{
'
id
'
:
json_schedulingunitdraft
[
'
id
'
],
'
object_type
'
:
'
scheduling_unit_draft
'
,
'
action
'
:
'
create
'
}
json_blob
[
'
object
'
]
=
json_schedulingunitdraft
recv_msg
=
self
.
msg_queue
.
popleft
()
self
.
assertEqual
(
json_blob
,
recv_msg
)
# TODO: Refactoring
json_blob
=
{}
json_taskdraft
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
TaskDraft
(
scheduling_unit_draft_url
=
json_schedulingunitdraft
[
'
url
'
]),
url_postfix
=
'
/task_draft
'
)
if
not
self
.
sync_event
.
wait
(
timeout
=
5
):
raise
TimeoutError
()
self
.
sync_event
.
clear
()
json_blob
=
{
'
id
'
:
json_taskdraft
[
'
id
'
],
'
object_type
'
:
'
task_draft
'
,
'
action
'
:
'
create
'
}
json_blob
[
'
object
'
]
=
json_taskdraft
recv_msg
=
self
.
msg_queue
.
popleft
()
self
.
assertEqual
(
json_blob
,
recv_msg
)
test_object
(
json_schedulingunitdraft
,
'
scheduling_unit_draft
'
,
'
create
'
)
# Test task_draft create
json_taskdraft
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
TaskDraft
(
scheduling_unit_draft_url
=
json_schedulingunitdraft
[
'
url
'
]),
url_postfix
=
'
/task_draft
'
)
test_object
(
json_taskdraft
,
'
task_draft
'
,
'
create
'
)
# TODO: create/update/delete objects like SubTask, TaskBlueprint etc
# TODO: check if the correct/expected json_blobs arrive in the websocket client
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