Skip to content
GitLab
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
771a2cae
Commit
771a2cae
authored
Jul 03, 2020
by
Samuel GAIST
Browse files
[test] Pre-commit cleanup
parent
195d2e5d
Changes
13
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/test/core.py
View file @
771a2cae
...
...
@@ -39,23 +39,28 @@ Base class for asset testing
"""
import
os
import
nose.tools
import
click
import
shutil
from
collections
import
namedtuple
from
functools
import
wraps
import
click
import
nose.tools
from
click.testing
import
CliRunner
from
beat.cmdline.scripts
import
main_cli
from
beat.core.test.utils
import
cleanup
from
beat.core.test.utils
import
skipif
from
beat.core.test.utils
import
slow
from
beat.cmdline.scripts
import
main_cli
from
..
import
common
from
.
import
platform
,
disconnected
,
prefix
,
tmp_prefix
,
user
,
token
from
.
import
disconnected
from
.
import
platform
from
.
import
prefix
from
.
import
tmp_prefix
from
.
import
token
from
.
import
user
if
not
disconnected
:
from
django.contrib.staticfiles.testing
import
LiveServerTestCase
...
...
beat/cmdline/test/test_algorithms.py
View file @
771a2cae
...
...
@@ -38,13 +38,14 @@
import
nose.tools
from
beat.core.algorithm
import
Storage
from
beat.core.algorithm
import
Algorithm
from
beat.core.algorithm
import
Storage
from
beat.core.dataformat
import
Storage
as
DFStorage
from
beat.core.library
import
Storage
as
LibStorage
from
.
import
core
from
.
import
tmp_prefix
,
prefix
from
.
import
prefix
from
.
import
tmp_prefix
class
TestOnline
(
core
.
OnlineAssetTestCase
):
...
...
beat/cmdline/test/test_cache.py
View file @
771a2cae
...
...
@@ -37,18 +37,19 @@
# Basic tests for the command line beat program: cache
import
os
import
nose.tools
from
click.testing
import
CliRunner
from
beat.core.test.utils
import
cleanup
,
slow
from
beat.cmdline.scripts
import
main_cli
from
beat.core.test.utils
import
cleanup
from
beat.core.test.utils
import
slow
from
.
import
prefix
from
.
import
tmp_prefix
from
.utils
import
index_experiment_dbs
from
.
import
prefix
,
tmp_prefix
def
call
(
*
args
,
**
kwargs
):
"""A central mechanism to call the main routine with the right parameters"""
...
...
beat/cmdline/test/test_config.py
View file @
771a2cae
...
...
@@ -37,22 +37,22 @@
# Basic tests for the command line beat program: config
import
os
import
shutil
import
click
import
nose.tools
import
simplejson
import
shutil
from
click.testing
import
CliRunner
from
beat.cmdline.scripts
import
main_cli
from
beat.core.plotter
import
Storage
as
PStorage
from
beat.core.test.utils
import
cleanup
from
beat.cmdline.scripts
import
main_cli
from
..
import
config
from
..
import
common
from
.
import
tmp_prefix
,
temp_cwd
from
..
import
config
from
.
import
temp_cwd
from
.
import
tmp_prefix
def
call
(
*
args
,
**
kwargs
):
...
...
beat/cmdline/test/test_databases.py
View file @
771a2cae
...
...
@@ -39,13 +39,15 @@
import
nose
import
nose.tools
from
beat.backend.python.test.test_database
import
INTEGERS_DBS
from
beat.backend.python.protocoltemplate
import
Storage
as
PTStorage
from
beat.core.database
import
Storage
,
Database
,
get_first_procotol_template
from
beat.backend.python.test.test_database
import
INTEGERS_DBS
from
beat.core.database
import
Database
from
beat.core.database
import
Storage
from
beat.core.database
import
get_first_procotol_template
from
.
import
core
from
.
import
prefix
,
tmp_prefix
from
.
import
prefix
from
.
import
tmp_prefix
class
TestLocal
(
core
.
AssetLocalTest
):
...
...
beat/cmdline/test/test_dataformats.py
View file @
771a2cae
...
...
@@ -36,10 +36,12 @@
# Basic tests for the command line beat program: dataformats
from
beat.core.dataformat
import
Storage
,
DataFormat
from
beat.core.dataformat
import
DataFormat
from
beat.core.dataformat
import
Storage
from
.
import
core
from
.
import
tmp_prefix
,
prefix
from
.
import
prefix
from
.
import
tmp_prefix
class
TestOnline
(
core
.
OnlineAssetTestCase
):
...
...
beat/cmdline/test/test_docker.py
View file @
771a2cae
...
...
@@ -36,20 +36,21 @@
# Docker based tests for algorithms and analyzers
import
os
import
json
import
os
import
shutil
import
pkg_resources
from
beat.core.test.utils
import
slow
import
nose.tools
import
pkg_resources
from
beat.backend.python.hash
import
hashDataset
from
beat.backend.python.hash
import
toPath
from
beat.core.database
import
Database
from
beat.core.test.utils
import
slow
from
.
import
core
from
.
import
prefix
,
tmp_prefix
from
.
import
prefix
from
.
import
tmp_prefix
instructions_dir
=
pkg_resources
.
resource_filename
(
__name__
,
"instructions"
)
...
...
beat/cmdline/test/test_libraries.py
View file @
771a2cae
...
...
@@ -36,11 +36,12 @@
# Basic tests for the command line beat program: protocoltemplates
from
beat.core.library
import
Storage
from
beat.core.library
import
Library
from
beat.core.library
import
Storage
from
.
import
core
from
.
import
tmp_prefix
,
prefix
from
.
import
prefix
from
.
import
tmp_prefix
class
TestLocal
(
core
.
AssetLocalTest
):
...
...
beat/cmdline/test/test_plotterparameters.py
View file @
771a2cae
...
...
@@ -38,8 +38,8 @@
import
nose.tools
from
beat.core.plotterparameter
import
Storage
,
Plotterparameter
from
beat.core.plotterparameter
import
Plotterparameter
from
beat.core.plotterparameter
import
Storage
from
beat.core.test.utils
import
slow
from
.
import
core
...
...
beat/cmdline/test/test_plotters.py
View file @
771a2cae
...
...
@@ -36,13 +36,15 @@
# Basic tests for the command line beat program: plotters
import
collections
import
os
import
nose.tools
import
simplejson
import
collections
from
beat.core.plotter
import
Plotter
from
beat.core.plotter
import
Storage
from
beat.core.test.utils
import
slow
from
beat.core.plotter
import
Storage
,
Plotter
from
.
import
core
from
.
import
tmp_prefix
...
...
beat/cmdline/test/test_shortcuts.py
View file @
771a2cae
...
...
@@ -36,24 +36,29 @@
import
difflib
import
nose.tools
def
test_shortcuts
():
shortcuts
=
{
'c'
:
'
config
'
,
'
co
'
:
'
config
'
,
'
cf
'
:
'
config
'
,
'
st
'
:
'
status
'
,
's'
:
'
status
'
,
'
db
'
:
'
databases
'
,
'
df
'
:
'
dataformats
'
,
'
lib
'
:
'
libraries
'
,
'l'
:
'
libraries
'
,
'
algo
'
:
'
algorithms
'
,
'
al
'
:
'
algorithms
'
,
'
tc
'
:
'
toolchains
'
,
'
exp
'
:
'
experiments
'
,
'
xp
'
:
'
experiments
'
,
}
shortcuts
=
{
"c"
:
"
config
"
,
"
co
"
:
"
config
"
,
"
cf
"
:
"
config
"
,
"
st
"
:
"
status
"
,
"s"
:
"
status
"
,
"
db
"
:
"
databases
"
,
"
df
"
:
"
dataformats
"
,
"
lib
"
:
"
libraries
"
,
"l"
:
"
libraries
"
,
"
algo
"
:
"
algorithms
"
,
"
al
"
:
"
algorithms
"
,
"
tc
"
:
"
toolchains
"
,
"
exp
"
:
"
experiments
"
,
"
xp
"
:
"
experiments
"
,
}
for
k
,
v
in
shortcuts
.
items
():
cmd
=
difflib
.
get_close_matches
(
k
,
set
(
shortcuts
.
values
()),
cutoff
=
0.2
)
assert
len
(
cmd
)
>
0
and
cmd
[
0
]
==
v
,
"`%s' != `%s' (%s)"
%
(
k
,
v
,
cmd
[
0
])
for
k
,
v
in
shortcuts
.
items
():
cmd
=
difflib
.
get_close_matches
(
k
,
set
(
shortcuts
.
values
()),
cutoff
=
0.2
)
nose
.
tools
.
assert_true
(
len
(
cmd
)
>
0
and
cmd
[
0
]
==
v
,
"`%s' != `%s' (%s)"
%
(
k
,
v
,
cmd
[
0
])
)
beat/cmdline/test/test_toolchains.py
View file @
771a2cae
...
...
@@ -37,9 +37,11 @@
# Basic tests for the command line beat program: toolchains
import
os
import
nose.tools
from
beat.core.toolchain
import
Storage
,
Toolchain
from
beat.core.toolchain
import
Storage
from
beat.core.toolchain
import
Toolchain
from
.
import
core
from
.
import
tmp_prefix
...
...
beat/cmdline/test/utils.py
View file @
771a2cae
...
...
@@ -37,20 +37,24 @@
Helper functions to run tests
"""
import
os
import
logging
import
pdb
import
os
import
pdb
# noqa
import
sys
from
beat.core.experiment
import
Experiment
from
beat.core.hash
import
toPath
from
beat.core.hash
import
hashDataset
from
beat.core.hash
import
toPath
from
.
import
prefix
,
tmp_prefix
from
.
import
prefix
from
.
import
tmp_prefix
def
set_trace
():
pdb
.
Pdb
(
stdin
=
sys
.
__stdin__
,
stdout
=
sys
.
__stdout__
).
set_trace
()
"""This is the currently official way to start pdb while in a click command"""
pdb
.
Pdb
(
stdin
=
sys
.
__stdin__
,
stdout
=
sys
.
__stdout__
).
set_trace
()
# noqa
def
index_experiment_dbs
(
experiment_name
):
"""
...
...
@@ -59,14 +63,19 @@ def index_experiment_dbs(experiment_name):
experiment
=
Experiment
(
prefix
,
experiment_name
)
assert
experiment
.
valid
,
'
\n
* %s'
%
'
\n
* '
.
join
(
experiment
.
errors
)
if
not
experiment
.
valid
:
raise
RuntimeError
(
"Invalid experiment:{}
\n
{}"
.
format
(
experiment_name
,
"
\n
* %s"
%
"
\n
* "
.
join
(
experiment
.
errors
)
)
)
for
block_name
,
infos
in
experiment
.
datasets
.
items
():
view
=
infos
[
'
database
'
].
view
(
infos
[
'
protocol
'
],
infos
[
'
set
'
])
filename
=
toPath
(
hashDataset
(
infos
[
'database'
].
name
,
infos
[
'
protocol
'
]
,
infos
[
'set'
])
,
suffix
=
'.db'
)
view
=
infos
[
"
database
"
].
view
(
infos
[
"
protocol
"
],
infos
[
"
set
"
])
filename
=
toPath
(
hashDataset
(
infos
[
"database"
].
name
,
infos
[
"
protocol
"
],
infos
[
"set"
])
,
suffix
=
".db"
,
)
view
.
index
(
os
.
path
.
join
(
tmp_prefix
,
filename
))
...
...
@@ -80,9 +89,12 @@ class MockLoggingHandler(logging.Handler):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
messages
=
{
'debug'
:
[],
'info'
:
[],
'warning'
:
[],
'error'
:
[],
'critical'
:
[],
'extra'
:
[]
"debug"
:
[],
"info"
:
[],
"warning"
:
[],
"error"
:
[],
"critical"
:
[],
"extra"
:
[],
}
super
(
MockLoggingHandler
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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