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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
slapos
Commits
a1a221b5
Commit
a1a221b5
authored
Oct 02, 2017
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: missing test for slapos.recipe:softwaretype
parent
057ab49a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
slapos/test/recipe/test_softwaretype.py
slapos/test/recipe/test_softwaretype.py
+102
-0
No files found.
slapos/test/recipe/test_softwaretype.py
0 → 100644
View file @
a1a221b5
import
os
import
mock
import
shutil
import
sys
import
tempfile
import
unittest
from
slapos.recipe
import
softwaretype
class
SoftwareTypeTest
(
unittest
.
TestCase
):
def
new_recipe
(
self
):
buildout
=
{
'buildout'
:
{
'bin-directory'
:
''
,
'find-links'
:
''
,
'allow-hosts'
:
''
,
'develop-eggs-directory'
:
''
,
'eggs-directory'
:
''
,
'python'
:
'testpython'
,
},
'testpython'
:
{
'executable'
:
sys
.
executable
,
},
'slap-connection'
:
{
'computer-id'
:
''
,
'partition-id'
:
''
,
'server-url'
:
''
,
'software-release-url'
:
''
,
},
# XXX softwaretype still uses slap_connection
'slap_connection'
:
{
'computer_id'
:
''
,
'partition_id'
:
''
,
'server_url'
:
''
,
'software_release_url'
:
''
,
}
}
options
=
{
}
return
softwaretype
.
Recipe
(
buildout
=
buildout
,
name
=
'softwaretype'
,
options
=
options
)
def
setUp
(
self
):
self
.
recipe
=
self
.
new_recipe
()
def
_mockComputerPartition
(
self
):
class
MockComputerPartition
(
object
):
_requested_state
=
'installed'
def
getInstanceParameterDict
(
self
):
return
{
'slap_software_type'
:
'test'
,
'ip_list'
:
[
(
'lo'
,
'127.0.0.1'
,),
(
'lo'
,
'::1'
,),
]
}
return
MockComputerPartition
()
@
mock
.
patch
(
'slapos.slap.slap.registerComputerPartition'
)
def
test_install
(
self
,
mock_client
):
mock_client
.
return_value
=
self
.
_mockComputerPartition
()
buildout_directory
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
buildout_directory
)
instance_buildout_file
=
os
.
path
.
join
(
buildout_directory
,
'instance-test.cfg'
)
with
open
(
instance_buildout_file
,
'w'
)
as
software_type_buildout
:
software_type_buildout
.
write
(
'''
[buildout]
parts = test
[test]
recipe = plone.recipe.command
command = touch file_created_when_running_instance
'''
)
self
.
recipe
.
buildout
[
'buildout'
][
'directory'
]
=
buildout_directory
# we use software_type "test", so buildout will be executed using instance-test.cfg
self
.
recipe
.
options
[
'test'
]
=
instance_buildout_file
# recipe reuse sys.argv to call the same buildout that its being running in
# but here we are not runing buildout, so we fake sys.argv
sys
.
argv
=
[
'buildout'
,
]
self
.
recipe
.
install
()
self
.
assertItemsEqual
(
os
.
listdir
(
buildout_directory
),
[
# standard buildout files
'instance-test.cfg'
,
'buildout-softwaretype.cfg'
,
'eggs'
,
'bin'
,
'parts'
,
'develop-eggs'
,
'.installed-softwaretype.cfg'
,
# the file we touch in the test to proove buildout has been running
'file_created_when_running_instance'
,
])
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