Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
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
Ayush Tiwari
slapos.recipe.build
Commits
b22b7042
Commit
b22b7042
authored
Sep 05, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2-spaces indentation
parent
2c3d314e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
75 deletions
+75
-75
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+75
-75
No files found.
slapos/recipe/build/tests.py
View file @
b22b7042
...
@@ -10,97 +10,97 @@ import unittest
...
@@ -10,97 +10,97 @@ import unittest
import
zc.buildout.testing
import
zc.buildout.testing
import
zc.buildout.tests
import
zc.buildout.tests
optionflags
=
(
doctest
.
ELLIPSIS
|
optionflags
=
(
doctest
.
ELLIPSIS
|
doctest
.
NORMALIZE_WHITESPACE
)
doctest
.
NORMALIZE_WHITESPACE
)
GIT_REPOSITORY
=
'http://git.erp5.org/repos/slapos.recipe.build.git'
GIT_REPOSITORY
=
'http://git.erp5.org/repos/slapos.recipe.build.git'
BAD_GIT_REPOSITORY
=
'http://git.erp5.org/repos/nowhere'
BAD_GIT_REPOSITORY
=
'http://git.erp5.org/repos/nowhere'
REVISION
=
'2566127'
REVISION
=
'2566127'
def
setUp
(
test
):
def
setUp
(
test
):
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
)
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
)
zc
.
buildout
.
testing
.
install_develop
(
'slapos.recipe.build'
,
test
)
zc
.
buildout
.
testing
.
install_develop
(
'slapos.recipe.build'
,
test
)
class
GitCloneNonInformativeTests
(
unittest
.
TestCase
):
class
GitCloneNonInformativeTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
dir
=
os
.
path
.
realpath
(
tempfile
.
mkdtemp
())
self
.
dir
=
os
.
path
.
realpath
(
tempfile
.
mkdtemp
())
def
tearDown
(
self
):
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
dir
)
shutil
.
rmtree
(
self
.
dir
)
for
var
in
os
.
environ
.
keys
():
for
var
in
os
.
environ
.
keys
():
if
var
.
startswith
(
'SRB_'
):
if
var
.
startswith
(
'SRB_'
):
del
os
.
environ
[
var
]
del
os
.
environ
[
var
]
def
write_file
(
self
,
filename
,
contents
,
mode
=
stat
.
S_IREAD
|
stat
.
S_IWUSR
):
def
write_file
(
self
,
filename
,
contents
,
mode
=
stat
.
S_IREAD
|
stat
.
S_IWUSR
):
path
=
os
.
path
.
join
(
self
.
dir
,
filename
)
path
=
os
.
path
.
join
(
self
.
dir
,
filename
)
fh
=
open
(
path
,
'w'
)
fh
=
open
(
path
,
'w'
)
fh
.
write
(
contents
)
fh
.
write
(
contents
)
fh
.
close
()
fh
.
close
()
os
.
chmod
(
path
,
mode
)
os
.
chmod
(
path
,
mode
)
return
path
return
path
def
make_recipe
(
self
,
buildout
,
name
,
options
):
def
make_recipe
(
self
,
buildout
,
name
,
options
):
from
slapos.recipe.gitclone
import
Recipe
from
slapos.recipe.gitclone
import
Recipe
parts_directory_path
=
os
.
path
.
join
(
self
.
dir
,
'test_parts'
)
parts_directory_path
=
os
.
path
.
join
(
self
.
dir
,
'test_parts'
)
bo
=
{
bo
=
{
'buildout'
:
{
'buildout'
:
{
'parts-directory'
:
parts_directory_path
,
'parts-directory'
:
parts_directory_path
,
'directory'
:
self
.
dir
,
'directory'
:
self
.
dir
,
}
}
}
}
bo
.
update
(
buildout
)
bo
.
update
(
buildout
)
return
Recipe
(
bo
,
name
,
options
)
return
Recipe
(
bo
,
name
,
options
)
def
test_using_download_cache_if_git_fails
(
self
):
def
test_using_download_cache_if_git_fails
(
self
):
from
slapos.recipe.gitclone
import
GIT_CLONE_ERROR_MESSAGE
,
\
from
slapos.recipe.gitclone
import
GIT_CLONE_ERROR_MESSAGE
,
\
GIT_CLONE_CACHE_ERROR_MESSAGE
GIT_CLONE_CACHE_ERROR_MESSAGE
recipe
=
self
.
make_recipe
({},
'test'
,
{
recipe
=
self
.
make_recipe
({},
'test'
,
{
'repository'
:
BAD_GIT_REPOSITORY
,
'repository'
:
BAD_GIT_REPOSITORY
,
'forbid-download-cache'
:
'false'
,
'forbid-download-cache'
:
'false'
,
})
})
os
.
chdir
(
self
.
dir
)
os
.
chdir
(
self
.
dir
)
try
:
try
:
recipe
.
install
()
recipe
.
install
()
# Should have raised before.
# Should have raised before.
self
.
assertTrue
(
False
)
self
.
assertTrue
(
False
)
except
zc
.
buildout
.
UserError
,
e
:
except
zc
.
buildout
.
UserError
,
e
:
self
.
assertEquals
(
e
.
message
,
GIT_CLONE_CACHE_ERROR_MESSAGE
)
self
.
assertEquals
(
e
.
message
,
GIT_CLONE_CACHE_ERROR_MESSAGE
)
def
test_not_using_download_cache_if_forbidden
(
self
):
def
test_not_using_download_cache_if_forbidden
(
self
):
from
slapos.recipe.gitclone
import
GIT_CLONE_ERROR_MESSAGE
,
\
from
slapos.recipe.gitclone
import
GIT_CLONE_ERROR_MESSAGE
,
\
GIT_CLONE_ERROR_MESSAGE
GIT_CLONE_ERROR_MESSAGE
recipe
=
self
.
make_recipe
({},
'test'
,
{
recipe
=
self
.
make_recipe
({},
'test'
,
{
'repository'
:
BAD_GIT_REPOSITORY
,
'repository'
:
BAD_GIT_REPOSITORY
,
'forbid-download-cache'
:
'true'
,
'forbid-download-cache'
:
'true'
,
})
})
os
.
chdir
(
self
.
dir
)
os
.
chdir
(
self
.
dir
)
try
:
try
:
recipe
.
install
()
recipe
.
install
()
# Should have raised before.
# Should have raised before.
self
.
assertTrue
(
False
)
self
.
assertTrue
(
False
)
except
zc
.
buildout
.
UserError
,
e
:
except
zc
.
buildout
.
UserError
,
e
:
self
.
assertEquals
(
e
.
message
,
GIT_CLONE_ERROR_MESSAGE
)
self
.
assertEquals
(
e
.
message
,
GIT_CLONE_ERROR_MESSAGE
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
((
suite
=
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
doctest
.
DocFileSuite
(
'README.rst'
,
'README.rst'
,
module_relative
=
False
,
module_relative
=
False
,
setUp
=
setUp
,
setUp
=
setUp
,
tearDown
=
zc
.
buildout
.
testing
.
buildoutTearDown
,
tearDown
=
zc
.
buildout
.
testing
.
buildoutTearDown
,
optionflags
=
optionflags
,
optionflags
=
optionflags
,
checker
=
renormalizing
.
RENormalizing
([
checker
=
renormalizing
.
RENormalizing
([
zc
.
buildout
.
testing
.
normalize_path
,
zc
.
buildout
.
testing
.
normalize_path
,
(
re
.
compile
(
r'http://localhost:\
d+
'), '
http
:
//
test
.
server
'),
(
re
.
compile
(
r'http://localhost:\
d+
'), '
http
:
//
test
.
server
'),
# Clean up the variable hashed filenames to avoid spurious test failures
# Clean up the variable hashed filenames to avoid spurious
(re.compile(r'
[
a
-
f0
-
9
]{
32
}
'), ''),
# test failures
]),
(re.compile(r'
[
a
-
f0
-
9
]{
32
}
'), ''),
),
]),
unittest.makeSuite(GitCloneNonInformativeTests),
),
))
unittest.makeSuite(GitCloneNonInformativeTests),
return suite
))
return suite
if __name__ == '
__main__
':
if __name__ == '
__main__
':
unittest.main(defaultTest='
test_suite
')
unittest.main(defaultTest='
test_suite
')
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