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
81966278
Commit
81966278
authored
4 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-417
: Add missing update actions, code clean up
parent
1cf660ec
No related branches found
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
+19
-17
19 additions, 17 deletions
SAS/TMSS/services/websocket/test/t_websocket_service.py
with
19 additions
and
17 deletions
SAS/TMSS/services/websocket/test/t_websocket_service.py
+
19
−
17
View file @
81966278
...
...
@@ -75,7 +75,6 @@ class TestSubtaskSchedulingService(unittest.TestCase):
on_close
=
on_close
)
self
.
ws
.
run_forever
()
websocket
.
enableTrace
(
True
)
self
.
t
=
Thread
(
target
=
thread_ws_starter
,
daemon
=
True
)
self
.
t
.
start
()
...
...
@@ -98,7 +97,7 @@ class TestSubtaskSchedulingService(unittest.TestCase):
def
test_01
(
self
):
'''
This test starts a
scheduling
service and tmss
, c
reates
a chain of subtasks, finishes the first, and
check
s
if
the successors are then schedul
ed.
This test starts a
websocket
service and tmss
. C
reates
, updates and deletes objects to
check if
json_blobs from the ws service are properly receiv
ed.
'''
logger
.
info
(
'
-- test_01_for_expected_behaviour --
'
)
...
...
@@ -120,74 +119,77 @@ class TestSubtaskSchedulingService(unittest.TestCase):
json_blob
[
'
object
'
]
=
json_test
self
.
assertEqual
(
json_blob
,
self
.
msg_queue
.
popleft
())
# Test creations
# Test scheduling_unit_draft create
logger
.
info
(
'
\n\n\n
Create su_draft
\n\n
'
)
su_draft
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
SchedulingUnitDraft
(),
'
/scheduling_unit_draft/
'
)
test_object
(
su_draft
,
self
.
ObjTypes
.
SCHED_UNIT_DRAFT
,
self
.
ObjActions
.
CREATE
)
# Test task_draft create
logger
.
info
(
'
\n\n\n
Create task_draft
\n\n
'
)
task_draft
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
TaskDraft
(
scheduling_unit_draft_url
=
su_draft
[
'
url
'
]),
'
/task_draft/
'
)
test_object
(
task_draft
,
self
.
ObjTypes
.
TASK_DRAFT
,
self
.
ObjActions
.
CREATE
)
# Test scheduling_unit_blueprint create
logger
.
info
(
'
\n\n\n
Create su_blueprint
\n\n
'
)
su_blueprint
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
SchedulingUnitBlueprint
(
scheduling_unit_draft_url
=
su_draft
[
'
url
'
]),
'
/scheduling_unit_blueprint/
'
)
test_object
(
su_blueprint
,
self
.
ObjTypes
.
SCHED_UNIT_BLUEPRINT
,
self
.
ObjActions
.
CREATE
)
# Test task_blueprint create
logger
.
info
(
'
\n\n\n
Create task_blueprint
\n\n
'
)
task_blueprint
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
TaskBlueprint
(
scheduling_unit_blueprint_url
=
su_blueprint
[
'
url
'
],
draft_url
=
task_draft
[
'
url
'
]),
'
/task_blueprint/
'
)
test_object
(
task_blueprint
,
self
.
ObjTypes
.
TASK_BLUEPRINT
,
self
.
ObjActions
.
CREATE
)
# Test subtask create
logger
.
info
(
'
\n\n\n
Create subtask
\n\n
'
)
subtask
=
self
.
test_data_creator
.
post_data_and_get_response_as_json_object
(
self
.
test_data_creator
.
Subtask
(
task_blueprint_url
=
task_blueprint
[
'
url
'
]),
'
/subtask/
'
)
test_object
(
subtask
,
self
.
ObjTypes
.
SUBTASK
,
self
.
ObjActions
.
CREATE
)
# TODO: Add task_draft and su_draft updates
# Test updates
with
self
.
tmss_test_env
.
create_tmss_client
()
as
client
:
# Test subtask update
logger
.
info
(
'
\n\n\n
Update subtask
\n\n
'
)
client
.
set_subtask_status
(
subtask
[
'
id
'
],
'
scheduled
'
)
subtask
=
requests
.
get
(
subtask
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
).
json
()
test_object
(
subtask
,
self
.
ObjTypes
.
SUBTASK
,
self
.
ObjActions
.
UPDATE
)
# Test task_blueprint update
logger
.
info
(
'
\n\n\n
Update task_blueprint
\n\n
'
)
task_blueprint
=
requests
.
get
(
task_blueprint
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
).
json
()
test_object
(
task_blueprint
,
self
.
ObjTypes
.
TASK_BLUEPRINT
,
self
.
ObjActions
.
UPDATE
)
# Test scheduling_unit_blueprint update
logger
.
info
(
'
\n\n\n
Update su_blueprint
\n\n
'
)
su_blueprint
=
requests
.
get
(
su_blueprint
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
).
json
()
test_object
(
su_blueprint
,
self
.
ObjTypes
.
SCHED_UNIT_BLUEPRINT
,
self
.
ObjActions
.
UPDATE
)
# Test scheduling_unit_draft update
su_draft
[
'
description
'
]
=
'
This is an update test
'
su_draft
=
requests
.
put
(
su_draft
[
'
url
'
],
json
=
su_draft
,
auth
=
self
.
test_data_creator
.
auth
).
json
()
test_object
(
su_draft
,
self
.
ObjTypes
.
SCHED_UNIT_DRAFT
,
self
.
ObjActions
.
UPDATE
)
# Test task_draft update
task_draft
[
'
description
'
]
=
'
This is an update test
'
task_draft
=
requests
.
put
(
task_draft
[
'
url
'
],
json
=
task_draft
,
auth
=
self
.
test_data_creator
.
auth
).
json
()
test_object
(
task_draft
,
self
.
ObjTypes
.
TASK_DRAFT
,
self
.
ObjActions
.
UPDATE
)
# Test deletions
# Test substask delete
logger
.
info
(
'
\n\n\n
Delete subtask
\n\n
'
)
# Test subtask delete
requests
.
delete
(
subtask
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
)
test_object
({
'
id
'
:
subtask
[
'
id
'
]},
self
.
ObjTypes
.
SUBTASK
,
self
.
ObjActions
.
DELETE
)
# Test task_blueprint delete
logger
.
info
(
'
\n\n\n
Delete task_blueprint
\n\n
'
)
requests
.
delete
(
task_blueprint
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
)
test_object
({
'
id
'
:
task_blueprint
[
'
id
'
]},
self
.
ObjTypes
.
TASK_BLUEPRINT
,
self
.
ObjActions
.
DELETE
)
# Test scheduling_unit_blueprint delete
logger
.
info
(
'
\n\n\n
Delete su_blueprint
\n\n
'
)
requests
.
delete
(
su_blueprint
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
)
test_object
({
'
id
'
:
su_blueprint
[
'
id
'
]},
self
.
ObjTypes
.
SCHED_UNIT_BLUEPRINT
,
self
.
ObjActions
.
DELETE
)
# Test task_draft delete
logger
.
info
(
'
\n\n\n
Delete task_draft
\n\n
'
)
requests
.
delete
(
task_draft
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
)
test_object
({
'
id
'
:
task_draft
[
'
id
'
]},
self
.
ObjTypes
.
TASK_DRAFT
,
self
.
ObjActions
.
DELETE
)
# Test scheduling_unit_draft delete
logger
.
info
(
'
\n\n\n
Delete su_draft
\n\n
'
)
requests
.
delete
(
su_draft
[
'
url
'
],
auth
=
self
.
test_data_creator
.
auth
)
test_object
({
'
id
'
:
su_draft
[
'
id
'
]},
self
.
ObjTypes
.
SCHED_UNIT_DRAFT
,
self
.
ObjActions
.
DELETE
)
...
...
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