Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Steven Gueguen
slapos
Commits
a1cee049
Commit
a1cee049
authored
Mar 01, 2024
by
Steven Gueguen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
18242fee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
8 deletions
+59
-8
software/warp10/test/test.py
software/warp10/test/test.py
+59
-8
No files found.
software/warp10/test/test.py
View file @
a1cee049
...
...
@@ -10,15 +10,66 @@ setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
class
TestWarp10
(
SlapOSInstanceTestCase
):
def
test_web
(
self
):
params
=
self
.
computer_partition
.
getConnectionParameterDict
()
def
setUp
(
self
):
self
.
params
=
self
.
computer_partition
.
getConnectionParameterDict
()
# check that tokens are not empty ( like @tomo suggested - EDIT: I misunderstood, his idea was to check this in a promise )
self
.
assertTrue
(
params
[
'read-token'
])
response
=
requests
.
get
(
params
[
'url'
])
# # maybe tokens are needed here for authentication, then it could be something like that instead:
# response = requests.get(url, headers={'read-token': params['read-token']})
##
## Check that tokens are not empty
##
def
test_tokens_availability
(
self
):
self
.
assertTrue
(
self
.
params
[
'read-token'
])
self
.
assertTrue
(
self
.
params
[
'write-token'
])
self
.
assertTrue
(
self
.
params
[
'sensision-read-token'
])
self
.
assertTrue
(
self
.
params
[
'sensision-write-token'
])
##
## Verify if check-url is ok
##
def
test_backend_url
(
self
):
response
=
requests
.
get
(
self
.
params
[
'backend-url'
]
+
"/api/v0/check"
)
self
.
assertEqual
(
requests
.
codes
[
'OK'
],
response
.
status_code
)
# self.assertIn("*** something expected in the HTML page ***", response.text)
##
## Test read/write/deletion with a set of read/write token
##
def
read_write_data
(
self
,
read_token
,
write_token
):
endpoint
=
self
.
params
[
'backend-url'
]
+
"/api/v0/exec"
gts
=
'slapos.test'
value
=
42
# Write
query
=
f"NEWGTS '
{
gts
}
' RENAME NOW NaN NaN NaN
{
value
}
ADDVALUE '
{
write_token
}
' UPDATE"
response
=
requests
.
post
(
endpoint
,
data
=
query
)
self
.
assertEqual
(
requests
.
codes
[
'OK'
],
response
.
status_code
)
# Read
query
=
f"[ '
{
read_token
}
' '
{
gts
}
' {{}} MAXLONG MAXLONG ] FETCH 0 GET VALUES"
response
=
requests
.
post
(
endpoint
,
data
=
query
)
self
.
assertEqual
(
requests
.
codes
[
'OK'
],
response
.
status_code
)
self
.
assertEqual
(
f"[[
{
value
}
]]"
,
response
.
text
)
# Delete
query
=
f"'
{
write_token
}
' '
{
gts
}
{{}}' NULL NULL MAXLONG DELETE"
print
(
query
)
response
=
requests
.
post
(
endpoint
,
data
=
query
)
self
.
assertEqual
(
requests
.
codes
[
'OK'
],
response
.
status_code
)
# Confirm deletion
query
=
f"[ '
{
read_token
}
' '
{
gts
}
' {{}} MAXLONG MAXLONG ] FETCH [] =="
response
=
requests
.
post
(
endpoint
,
data
=
query
)
self
.
assertEqual
(
requests
.
codes
[
'OK'
],
response
.
status_code
)
self
.
assertEqual
(
f"[true]"
,
response
.
text
)
##
## Test standard token
##
def
test_standard_token
(
self
):
self
.
read_write_data
(
self
.
params
[
'read-token'
],
self
.
params
[
'write-token'
])
##
## Test sensision token
##
def
test_sensision_token
(
self
):
self
.
read_write_data
(
self
.
params
[
'sensision-read-token'
],
self
.
params
[
'sensision-write-token'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment