Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.cmdline
Commits
96f3153d
Commit
96f3153d
authored
Oct 15, 2019
by
Samuel GAIST
Browse files
[test][toolchains] Refactor tests to use new live server based test class
parent
fb7cb55f
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/test/test_toolchains.py
View file @
96f3153d
...
...
@@ -38,122 +38,90 @@
import
os
import
nose.tools
import
click
from
click.testing
import
CliRunner
from
beat.cmdline.scripts
import
main_cli
from
beat.core.test.utils
import
slow
,
cleanup
,
skipif
from
beat.core.test.utils
import
slow
from
beat.core.toolchain
import
Storage
,
Toolchain
from
.
import
core
from
.
import
platform
,
disconnected
,
prefix
,
tmp_prefix
,
user
,
token
def
call
(
*
args
,
**
kwargs
):
"""A central mechanism to call the main routine with the right parameters"""
use_prefix
=
kwargs
.
get
(
"prefix"
,
prefix
)
use_platform
=
kwargs
.
get
(
"platform"
,
platform
)
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
result
=
runner
.
invoke
(
main_cli
.
main
,
[
"--test-mode"
,
"--prefix"
,
use_prefix
,
"--token"
,
token
,
"--user"
,
user
,
"--platform"
,
use_platform
,
"toolchains"
,
]
+
list
(
args
),
catch_exceptions
=
False
,
)
if
result
.
exit_code
!=
0
:
click
.
echo
(
result
.
output
)
return
result
.
exit_code
@
slow
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_remote_list
():
nose
.
tools
.
eq_
(
call
(
"list"
,
"--remote"
),
0
)
@
slow
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_pull_one
(
obj
=
None
):
obj
=
obj
or
"user/single/1"
nose
.
tools
.
eq_
(
call
(
"pull"
,
obj
,
prefix
=
tmp_prefix
),
0
)
s
=
Storage
(
tmp_prefix
,
obj
)
nose
.
tools
.
assert_true
(
s
.
exists
())
@
slow
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_pull_all
():
nose
.
tools
.
eq_
(
call
(
"pull"
,
prefix
=
tmp_prefix
),
0
)
@
slow
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_diff
():
obj
=
"user/single/1"
nose
.
tools
.
eq_
(
call
(
"pull"
,
obj
,
prefix
=
tmp_prefix
),
0
)
from
.
import
tmp_prefix
# quickly modify the user toolchain:
f
=
Toolchain
(
tmp_prefix
,
obj
)
f
.
data
[
"representation"
][
"blocks"
][
"echo"
][
"height"
]
=
2
f
.
write
()
nose
.
tools
.
eq_
(
call
(
"diff"
,
obj
,
prefix
=
tmp_prefix
),
0
)
class
TestOnlineToolchains
(
core
.
OnlineAssetTestCase
):
asset_type
=
"toolchain"
@
slow
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_status
():
test_diff
()
test_pull_one
()
nose
.
tools
.
eq_
(
call
(
"status"
,
prefix
=
tmp_prefix
),
0
)
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_push_and_delete
():
obj
=
"user/newobject/1"
TestToolchainLocal
.
create
(
obj
)
# now push the new object and then delete it remotely
nose
.
tools
.
eq_
(
call
(
"push"
,
obj
,
prefix
=
tmp_prefix
),
0
)
nose
.
tools
.
eq_
(
call
(
"rm"
,
"--remote"
,
obj
,
prefix
=
tmp_prefix
),
0
)
@
nose
.
tools
.
with_setup
(
teardown
=
cleanup
)
@
skipif
(
disconnected
,
"missing test platform (%s)"
%
platform
)
def
test_draw
():
obj
=
"user/double_triangle/1"
test_pull_one
(
obj
)
# now push the new object and then delete it remotely
nose
.
tools
.
eq_
(
call
(
"draw"
,
"--path=%s"
%
tmp_prefix
,
prefix
=
tmp_prefix
),
0
)
@
slow
@
core
.
skip_disconnected
def
test_remote_list
(
self
):
exit_code
,
output
=
self
.
call
(
"list"
,
"--remote"
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
@
slow
@
core
.
skip_disconnected
def
test_pull_one
(
self
,
obj
=
None
):
obj
=
obj
or
"user/single/1"
exit_code
,
output
=
self
.
call
(
"pull"
,
obj
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
s
=
Storage
(
tmp_prefix
,
obj
)
nose
.
tools
.
assert_true
(
s
.
exists
())
@
slow
@
core
.
skip_disconnected
def
test_pull_all
(
self
):
exit_code
,
output
=
self
.
call
(
"pull"
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
@
slow
@
core
.
skip_disconnected
def
test_diff
(
self
):
obj
=
"user/single/1"
exit_code
,
output
=
self
.
call
(
"pull"
,
obj
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
# quickly modify the user toolchain:
f
=
Toolchain
(
tmp_prefix
,
obj
)
f
.
data
[
"representation"
][
"blocks"
][
"echo"
][
"height"
]
=
2
f
.
write
()
exit_code
,
output
=
self
.
call
(
"diff"
,
obj
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
@
slow
@
core
.
skip_disconnected
def
test_status
(
self
):
self
.
test_diff
()
self
.
test_pull_one
()
exit_code
,
output
=
self
.
call
(
"status"
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
@
core
.
skip_disconnected
def
test_push_and_delete
(
self
):
obj
=
"user/newobject/1"
TestToolchainLocal
.
create
(
obj
)
# now push the new object and then delete it remotely
exit_code
,
output
=
self
.
call
(
"push"
,
obj
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
exit_code
,
output
=
self
.
call
(
"rm"
,
"--remote"
,
obj
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
@
core
.
skip_disconnected
def
test_draw
(
self
):
obj
=
"user/double_triangle/1"
self
.
test_pull_one
(
obj
)
# now push the new object and then delete it remotely
exit_code
,
output
=
self
.
call
(
"draw"
,
"--path=%s"
%
tmp_prefix
,
prefix
=
tmp_prefix
)
nose
.
tools
.
eq_
(
exit_code
,
0
,
output
)
nose
.
tools
.
assert_true
(
os
.
path
.
exists
(
os
.
path
.
join
(
tmp_prefix
,
"toolchains"
,
obj
+
".png"
))
)
nose
.
tools
.
assert_true
(
os
.
path
.
exists
(
os
.
path
.
join
(
tmp_prefix
,
"toolchains"
,
obj
+
".dot"
))
)
nose
.
tools
.
assert_true
(
os
.
path
.
exists
(
os
.
path
.
join
(
tmp_prefix
,
"toolchains"
,
obj
+
".png"
))
)
nose
.
tools
.
assert_true
(
os
.
path
.
exists
(
os
.
path
.
join
(
tmp_prefix
,
"toolchains"
,
obj
+
".dot"
))
)
class
TestToolchainLocal
(
core
.
AssetLocalTest
):
...
...
Write
Preview
Supports
Markdown
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