Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Lu Xu
slapos.core
Commits
5398cd39
Commit
5398cd39
authored
May 16, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover caching of instance list.
parent
371972b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+89
-0
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
+1
-1
No files found.
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
View file @
5398cd39
...
...
@@ -1115,6 +1115,11 @@ class TestInstancePUT(VifibSlaposRestAPIV1InstanceMixin):
self
.
assertInstancePUTSimulatorEmpty
()
class
TestInstanceGETlist
(
VifibSlaposRestAPIV1InstanceMixin
):
def
assertLastModifiedHeader
(
self
):
calculated
=
rfc1123_date
(
self
.
portal
.
software_instance_module
\
.
bobobase_modification_time
())
self
.
assertEqual
(
calculated
,
self
.
response
.
getheader
(
'Last-Modified'
))
def
test
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
...
...
@@ -1123,6 +1128,90 @@ class TestInstanceGETlist(VifibSlaposRestAPIV1InstanceMixin):
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertResponseJson
()
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertEqual
({
"list"
:
[
'/'
.
join
([
self
.
api_url
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()])]
},
self
.
json_response
)
def
test_if_modified_since_equal
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
self
.
portal
.
software_instance_module
\
.
bobobase_modification_time
())})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
304
)
def
test_if_modified_since_after
(
self
):
# wait three seconds before continuing in order to not hit time precision
# issue, as test needs to provide date with second precision after
# last modification of software instance and *before* now()
time
.
sleep
(
3
)
# add 2 seconds, as used rfc1123_date will ceil the second in response and
# one more second will be required in order to be *after* the modification time
if_modified
=
self
.
portal
.
software_instance_module
\
.
bobobase_modification_time
().
timeTime
()
+
2
# check the test: is calculated time *before* now?
self
.
assertTrue
(
int
(
if_modified
)
<
int
(
DateTime
().
timeTime
()))
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
self
.
portal
.
software_instance_module
\
.
bobobase_modification_time
())})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
304
)
def
test_if_modified_since_before
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
self
.
portal
.
software_instance_module
\
.
bobobase_modification_time
()
-
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertResponseJson
()
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertEqual
({
"list"
:
[
'/'
.
join
([
self
.
api_url
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()])]
},
self
.
json_response
)
def
test_if_modified_since_date_not_date
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
'This Is Not A date'
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertResponseJson
()
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertEqual
({
"list"
:
[
'/'
.
join
([
self
.
api_url
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()])]
},
self
.
json_response
)
def
test_if_modified_since_date_future
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
DateTime
()
+
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertResponseJson
()
self
.
assertLastModifiedHeader
()
self
.
assertCacheControlHeader
()
self
.
assertEqual
({
"list"
:
[
'/'
.
join
([
self
.
api_url
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()])]
...
...
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
5398cd39
54
\ No newline at end of file
55
\ No newline at end of file
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