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
Nicolas Wavrant
slapos.core
Commits
2cb7a0f5
Commit
2cb7a0f5
authored
Aug 11, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new test for Software class.
parent
b5313dff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
slapos/tests/slapobject.py
slapos/tests/slapobject.py
+87
-0
No files found.
slapos/tests/slapobject.py
0 → 100644
View file @
2cb7a0f5
from
slapos.grid
import
SlapObject
from
slapos.grid
import
utils
from
slapos.tests.slapgrid
import
BasicMixin
import
os
import
unittest
import
tempfile
import
sys
def
mockBootstrapBuildout
(
*
args
,
**
kwargs
):
print
args
,
kwargs
utils
.
bootstrapBuildout
=
mockBootstrapBuildout
def
mockLaunchBuildout
(
*
args
,
**
kwargs
):
print
args
,
kwargs
utils
.
launchBuildout
=
mockLaunchBuildout
class
TestSoftwareSlapObject
(
BasicMixin
,
unittest
.
TestCase
):
"""
Test for Software class.
"""
def
setUp
(
self
):
BasicMixin
.
setUp
(
self
)
os
.
mkdir
(
self
.
software_root
)
self
.
output_file
=
tempfile
.
NamedTemporaryFile
()
self
.
stdout
=
sys
.
stdout
self
.
signature_private_key_file
=
'/signature/private/key_file'
self
.
upload_cache_url
=
'http://example.com/uploadcache'
self
.
upload_dir_url
=
'http://example.com/uploaddir'
def
tearDown
(
self
):
BasicMixin
.
tearDown
(
self
)
self
.
output_file
.
close
()
# Utils methods
def
_printToFile
(
self
):
self
.
output_file
.
seek
(
0
)
sys
.
stdout
=
self
.
output_file
def
_printToScreen
(
self
):
self
.
output_file
.
seek
(
0
)
sys
.
stdout
=
self
.
stdout
# Test methods
def
test_software_install_with_networkcache
(
self
):
"""
Check if the networkcache parameters are propagated.
"""
software
=
SlapObject
.
Software
(
url
=
'http://example.com/software.cfg'
,
software_root
=
self
.
software_root
,
console
=
False
,
buildout
=
self
.
buildout
,
signature_private_key_file
=
'/signature/private/key_file'
,
upload_cache_url
=
'http://example.com/uploadcache'
,
upload_dir_url
=
'http://example.com/uploaddir'
)
self
.
_printToFile
()
software
.
install
()
self
.
_printToScreen
()
content
=
self
.
output_file
.
read
()
self
.
assertTrue
(
'networkcache'
in
content
)
self
.
assertTrue
(
self
.
upload_cache_url
in
content
)
self
.
assertTrue
(
self
.
upload_dir_url
in
content
)
self
.
assertTrue
(
self
.
signature_private_key_file
in
content
)
def
test_software_install_without_networkcache
(
self
):
"""
Check if the networkcache parameters are not propagated if they are not
available.
"""
software
=
SlapObject
.
Software
(
url
=
'http://example.com/software.cfg'
,
software_root
=
self
.
software_root
,
console
=
False
,
buildout
=
self
.
buildout
)
self
.
_printToFile
()
software
.
install
()
self
.
_printToScreen
()
content
=
self
.
output_file
.
read
()
self
.
assertFalse
(
'networkcache'
in
content
)
self
.
assertFalse
(
self
.
upload_cache_url
in
content
)
self
.
assertFalse
(
self
.
upload_dir_url
in
content
)
self
.
assertFalse
(
self
.
signature_private_key_file
in
content
)
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