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
Xiaowu Zhang
slapos.core
Commits
4c53e75a
Commit
4c53e75a
authored
May 10, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fine tune simulator.
parent
03bc7006
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
20 deletions
+24
-20
master/bt5/vifib_slapos_rest_api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
..._api_v1_test/TestTemplateItem/testVifibSlaposRestAPIV1.py
+23
-19
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 @
4c53e75a
...
@@ -10,15 +10,23 @@ import tempfile
...
@@ -10,15 +10,23 @@ import tempfile
import
os
import
os
class
Simulator
:
class
Simulator
:
def
__init__
(
self
,
outfile
):
def
__init__
(
self
,
outfile
,
method
):
self
.
outfile
=
outfile
self
.
outfile
=
outfile
self
.
method
=
method
def
__call__
(
self
,
*
args
,
**
kwargs
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
"""Simulation Method"""
"""Simulation Method"""
open
(
self
.
outfile
,
'a'
).
write
(
'recargs = %r
\
n
reckwargs = %r'
%
(
args
,
old
=
open
(
self
.
outfile
,
'r'
).
read
()
kwargs
))
if
old
:
l
=
eval
(
old
)
else
:
l
=
[]
l
.
append
({
'recmethod'
:
self
.
method
,
'recargs'
:
args
,
'reckwargs'
:
kwargs
})
open
(
self
.
outfile
,
'w'
).
write
(
repr
(
l
))
class
RaisingSimulator
(
Simulator
)
:
class
RaisingSimulator
:
def
__init__
(
self
,
exception
):
def
__init__
(
self
,
exception
):
self
.
exception
=
exception
self
.
exception
=
exception
...
@@ -81,8 +89,8 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
...
@@ -81,8 +89,8 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
self
.
person_request_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
person_request_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
customer
,
self
.
customer_reference
=
self
.
createPerson
()
self
.
customer
,
self
.
customer_reference
=
self
.
createPerson
()
self
.
customer
.
requestSoftwareInstance
=
Simulator
(
self
.
customer
.
requestSoftwareInstance
=
Simulator
(
self
.
person_request_simulator
,
self
.
person_request_simulator
)
'requestSoftwareInstance'
)
transaction
.
commit
()
transaction
.
commit
()
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
...
@@ -121,10 +129,7 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
...
@@ -121,10 +129,7 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
self
.
assertEqual
(
open
(
self
.
person_request_simulator
).
read
(),
''
)
self
.
assertEqual
(
open
(
self
.
person_request_simulator
).
read
(),
''
)
def
assertPersonRequestSimulator
(
self
,
args
,
kwargs
):
def
assertPersonRequestSimulator
(
self
,
args
,
kwargs
):
# fillup magic
stored
=
eval
(
open
(
self
.
person_request_simulator
).
read
())
recargs
=
()
reckwargs
=
{}
exec
(
open
(
self
.
person_request_simulator
).
read
())
# do the same translation magic as in tool
# do the same translation magic as in tool
kwargs
=
kwargs
.
copy
()
kwargs
=
kwargs
.
copy
()
for
k_j
,
k_i
in
(
for
k_j
,
k_i
in
(
...
@@ -137,8 +142,9 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
...
@@ -137,8 +142,9 @@ class VifibSlaposRestAPIV1Mixin(TestVifibSlapWebServiceMixin):
(
'status'
,
'state'
)
(
'status'
,
'state'
)
):
):
kwargs
[
k_i
]
=
kwargs
.
pop
(
k_j
)
kwargs
[
k_i
]
=
kwargs
.
pop
(
k_j
)
self
.
assertEqual
(
args
,
recargs
)
self
.
assertEqual
(
stored
,
self
.
assertEqual
(
kwargs
,
reckwargs
)
[{
'recargs'
:
args
,
'reckwargs'
:
kwargs
,
'recmethod'
:
'requestSoftwareInstance'
}])
class
TestInstanceRequest
(
VifibSlaposRestAPIV1Mixin
):
class
TestInstanceRequest
(
VifibSlaposRestAPIV1Mixin
):
def
test_not_logged_in
(
self
):
def
test_not_logged_in
(
self
):
...
@@ -608,7 +614,7 @@ class VifibSlaposRestAPIV1BangMixin(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -608,7 +614,7 @@ class VifibSlaposRestAPIV1BangMixin(VifibSlaposRestAPIV1InstanceMixin):
super
(
VifibSlaposRestAPIV1BangMixin
,
self
).
afterSetUp
()
super
(
VifibSlaposRestAPIV1BangMixin
,
self
).
afterSetUp
()
self
.
instance_bang_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
instance_bang_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
software_instance
.
reportComputerPartitionBang
=
Simulator
(
self
.
software_instance
.
reportComputerPartitionBang
=
Simulator
(
self
.
instance_bang_simulator
)
self
.
instance_bang_simulator
,
'reportComputerPartitionBang'
)
transaction
.
commit
()
transaction
.
commit
()
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
...
@@ -620,14 +626,12 @@ class VifibSlaposRestAPIV1BangMixin(VifibSlaposRestAPIV1InstanceMixin):
...
@@ -620,14 +626,12 @@ class VifibSlaposRestAPIV1BangMixin(VifibSlaposRestAPIV1InstanceMixin):
self
.
assertEqual
(
open
(
self
.
instance_bang_simulator
).
read
(),
''
)
self
.
assertEqual
(
open
(
self
.
instance_bang_simulator
).
read
(),
''
)
def
assertInstanceBangSimulator
(
self
,
args
,
kwargs
):
def
assertInstanceBangSimulator
(
self
,
args
,
kwargs
):
# fillup magic
stored
=
eval
(
open
(
self
.
instance_bang_simulator
).
read
())
recargs
=
()
reckwargs
=
{}
exec
(
open
(
self
.
instance_bang_simulator
).
read
())
# do the same translation magic as in workflow
# do the same translation magic as in workflow
kwargs
[
'comment'
]
=
kwargs
.
pop
(
'log'
)
kwargs
[
'comment'
]
=
kwargs
.
pop
(
'log'
)
self
.
assertEqual
(
args
,
recargs
)
self
.
assertEqual
(
stored
,
self
.
assertEqual
(
kwargs
,
reckwargs
)
[{
'recargs'
:
args
,
'reckwargs'
:
kwargs
,
'recmethod'
:
'reportComputerPartitionBang'
}])
class
TestInstancePOSTbang
(
VifibSlaposRestAPIV1BangMixin
):
class
TestInstancePOSTbang
(
VifibSlaposRestAPIV1BangMixin
):
def
test
(
self
):
def
test
(
self
):
...
...
master/bt5/vifib_slapos_rest_api_v1_test/bt/revision
View file @
4c53e75a
36
37
\ 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