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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
8a119d6f
Commit
8a119d6f
authored
May 11, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test If-Modified-Since logic.
parent
e7ba9bdd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
1 deletion
+127
-1
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+126
-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 @
8a119d6f
...
@@ -9,6 +9,8 @@ import json
...
@@ -9,6 +9,8 @@ import json
import
tempfile
import
tempfile
import
os
import
os
from
App.Common
import
rfc1123_date
from
App.Common
import
rfc1123_date
from
DateTime
import
DateTime
import
time
class
Simulator
:
class
Simulator
:
def
__init__
(
self
,
outfile
,
method
):
def
__init__
(
self
,
outfile
,
method
):
...
@@ -537,6 +539,130 @@ class TestInstanceGET(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -537,6 +539,130 @@ class TestInstanceGET(VifibSlaposRestAPIV1InstanceMixin):
"sla"
:
{
"computer_guid"
:
"SOMECOMP"
}},
"sla"
:
{
"computer_guid"
:
"SOMECOMP"
}},
self
.
json_response
)
self
.
json_response
)
def
test_if_modified_since_equal
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
self
.
software_instance
\
.
getModificationDate
())})
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
.
software_instance
.
getModificationDate
().
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'
,
self
.
software_instance
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
DateTime
(
if_modified
))})
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'
,
self
.
software_instance
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
self
.
software_instance
\
.
getModificationDate
()
-
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertResponseJson
()
self
.
assertEqual
({
"status"
:
"draft"
,
"connection"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"https://niut:pass@example.com:4567/arfarf/oink?m=1#4.5"
},
"partition"
:
{
"public_ip"
:
[],
"tap_interface"
:
""
,
"private_ip"
:
[]},
"slave"
:
False
,
"children_list"
:
[],
"title"
:
"Template Software Instance"
,
"software_type"
:
"RootSoftwareInstance"
,
"parameter"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"valueof2"
},
"software_release"
:
""
,
"sla"
:
{
"computer_guid"
:
"SOMECOMP"
}},
self
.
json_response
)
def
test_if_modified_since_date_not_date
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
'This Is Not A date'
})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertResponseJson
()
self
.
assertEqual
({
"status"
:
"draft"
,
"connection"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"https://niut:pass@example.com:4567/arfarf/oink?m=1#4.5"
},
"partition"
:
{
"public_ip"
:
[],
"tap_interface"
:
""
,
"private_ip"
:
[]},
"slave"
:
False
,
"children_list"
:
[],
"title"
:
"Template Software Instance"
,
"software_type"
:
"RootSoftwareInstance"
,
"parameter"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"valueof2"
},
"software_release"
:
""
,
"sla"
:
{
"computer_guid"
:
"SOMECOMP"
}},
self
.
json_response
)
def
test_if_modified_since_date_future
(
self
):
self
.
connection
.
request
(
method
=
'GET'
,
url
=
'/'
.
join
([
self
.
api_path
,
'instance'
,
self
.
software_instance
.
getRelativeUrl
()]),
headers
=
{
'REMOTE_USER'
:
self
.
customer_reference
,
'If-Modified-Since'
:
rfc1123_date
(
DateTime
()
+
1
)})
self
.
prepareResponse
()
self
.
assertBasicResponse
()
self
.
assertResponseCode
(
200
)
self
.
assertLastModifiedHeader
()
self
.
assertResponseJson
()
self
.
assertEqual
({
"status"
:
"draft"
,
"connection"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"https://niut:pass@example.com:4567/arfarf/oink?m=1#4.5"
},
"partition"
:
{
"public_ip"
:
[],
"tap_interface"
:
""
,
"private_ip"
:
[]},
"slave"
:
False
,
"children_list"
:
[],
"title"
:
"Template Software Instance"
,
"software_type"
:
"RootSoftwareInstance"
,
"parameter"
:
{
"parameter1"
:
"valueof1"
,
"parameter2"
:
"valueof2"
},
"software_release"
:
""
,
"sla"
:
{
"computer_guid"
:
"SOMECOMP"
}},
self
.
json_response
)
def
test_other_one
(
self
):
def
test_other_one
(
self
):
person
,
person_reference
=
self
.
createPerson
()
person
,
person_reference
=
self
.
createPerson
()
self
.
connection
.
request
(
method
=
'GET'
,
self
.
connection
.
request
(
method
=
'GET'
,
...
...
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
8a119d6f
40
41
\ No newline at end of file
\ 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