Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Kazuhiko Shiozaki
slapos.toolbox
Commits
2282ddda
Commit
2282ddda
authored
Aug 11, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test / runner: new test for opening new Software Release
parent
d631025a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
slapos/test/test_runner.py
slapos/test/test_runner.py
+47
-1
No files found.
slapos/test/test_runner.py
View file @
2282ddda
...
@@ -2,18 +2,28 @@ import mock
...
@@ -2,18 +2,28 @@ import mock
import
os
import
os
import
string
import
string
import
random
import
random
import
supervisor
import
thread
import
unittest
import
unittest
from
slapos.runner
import
views
as
runner_views
from
slapos.runner
import
views
as
runner_views
from
slapos.runner
import
utils
as
runner_utils
from
slapos.runner
import
utils
as
runner_utils
from
slapos.runner
import
sup_process
as
runner_process
from
slapos.runner
import
sup_process
as
runner_process
class
TestRunner
(
unittest
.
TestCase
):
class
TestRunner
BackEnd
(
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
htpasswd_file
=
os
.
path
.
join
(
*
(
os
.
getcwd
(),
'.htpasswd'
))
htpasswd_file
=
os
.
path
.
join
(
*
(
os
.
getcwd
(),
'.htpasswd'
))
if
os
.
path
.
exists
(
htpasswd_file
):
if
os
.
path
.
exists
(
htpasswd_file
):
os
.
remove
(
htpasswd_file
)
os
.
remove
(
htpasswd_file
)
def
_startSupervisord
(
self
):
cwd
=
os
.
getcwd
()
supervisord_config_file
=
os
.
path
.
join
(
cwd
,
'supervisord.conf'
)
open
(
supervisord_config_file
,
'w'
).
write
(
"""
"""
)
supervisord
=
supervisor
.
supervisord
.
Supervisord
(
'-c'
,
supervisord_config_file
)
thread
.
start_new_thread
()
def
test_UserCanLoginAndUpdateCredentials
(
self
):
def
test_UserCanLoginAndUpdateCredentials
(
self
):
"""
"""
* Create a user with createNewUser
* Create a user with createNewUser
...
@@ -120,6 +130,42 @@ class TestRunner(unittest.TestCase):
...
@@ -120,6 +130,42 @@ class TestRunner(unittest.TestCase):
self
.
_runSlapgridWithLockMakesCorrectCallsToSupervisord
(
self
.
_runSlapgridWithLockMakesCorrectCallsToSupervisord
(
runner_utils
.
runInstanceWithLock
,
'slapgrid-cp'
)
runner_utils
.
runInstanceWithLock
,
'slapgrid-cp'
)
@
mock
.
patch
(
'os.path.exists'
)
@
mock
.
patch
(
'os.remove'
)
@
mock
.
patch
(
'slapos.runner.sup_process.stopProcess'
)
@
mock
.
patch
(
'slapos.runner.utils.open'
)
@
mock
.
patch
(
'slapos.runner.utils.startProxy'
)
@
mock
.
patch
(
'slapos.runner.utils.stopProxy'
)
@
mock
.
patch
(
'slapos.runner.utils.removeProxyDb'
)
@
mock
.
patch
(
'slapos.runner.utils.removeInstanceRoot'
)
def
test_changingSRUpdatesProjectFileWithExistingPath
(
self
,
mock_removeInstanceRoot
,
mock_removeProxyDb
,
mock_stopProxy
,
mock_startProxy
,
mock_open
,
mock_stopProcess
,
mock_remove
,
mock_path_exists
):
cwd
=
os
.
getcwd
()
config
=
{
'etc_dir'
:
os
.
path
.
join
(
cwd
,
'etc'
),
'workspace'
:
os
.
path
.
join
(
cwd
,
'srv'
,
'runner'
)}
projectpath
=
'workspace/project/software/'
self
.
assertNotEqual
(
runner_utils
.
realpath
(
config
,
projectpath
,
\
check_exist
=
False
),
''
)
# If projectpath doesn't exist, .project file shouldn't be written
mock_path_exists
.
return_value
=
False
result
=
runner_utils
.
configNewSR
(
config
,
projectpath
)
self
.
assertFalse
(
result
)
# If projectpath exist, .project file should be overwritten
mock_path_exists
.
return_value
=
True
result
=
runner_utils
.
configNewSR
(
config
,
projectpath
)
self
.
assertTrue
(
result
)
mock_open
.
assert_has_calls
([
mock
.
call
().
write
(
projectpath
)])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
random
.
seed
()
random
.
seed
()
...
...
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