Commit 771a2cae authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test] Pre-commit cleanup

parent 195d2e5d
...@@ -39,23 +39,28 @@ Base class for asset testing ...@@ -39,23 +39,28 @@ Base class for asset testing
""" """
import os import os
import nose.tools
import click
import shutil import shutil
from collections import namedtuple from collections import namedtuple
from functools import wraps from functools import wraps
import click
import nose.tools
from click.testing import CliRunner 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 cleanup
from beat.core.test.utils import skipif from beat.core.test.utils import skipif
from beat.core.test.utils import slow from beat.core.test.utils import slow
from beat.cmdline.scripts import main_cli
from .. import common from .. import common
from . import disconnected
from . import platform, disconnected, prefix, tmp_prefix, user, token from . import platform
from . import prefix
from . import tmp_prefix
from . import token
from . import user
if not disconnected: if not disconnected:
from django.contrib.staticfiles.testing import LiveServerTestCase from django.contrib.staticfiles.testing import LiveServerTestCase
......
...@@ -38,13 +38,14 @@ ...@@ -38,13 +38,14 @@
import nose.tools import nose.tools
from beat.core.algorithm import Storage
from beat.core.algorithm import Algorithm from beat.core.algorithm import Algorithm
from beat.core.algorithm import Storage
from beat.core.dataformat import Storage as DFStorage from beat.core.dataformat import Storage as DFStorage
from beat.core.library import Storage as LibStorage from beat.core.library import Storage as LibStorage
from . import core from . import core
from . import tmp_prefix, prefix from . import prefix
from . import tmp_prefix
class TestOnline(core.OnlineAssetTestCase): class TestOnline(core.OnlineAssetTestCase):
......
...@@ -37,18 +37,19 @@ ...@@ -37,18 +37,19 @@
# Basic tests for the command line beat program: cache # Basic tests for the command line beat program: cache
import os import os
import nose.tools import nose.tools
from click.testing import CliRunner from click.testing import CliRunner
from beat.core.test.utils import cleanup, slow
from beat.cmdline.scripts import main_cli 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 .utils import index_experiment_dbs
from . import prefix, tmp_prefix
def call(*args, **kwargs): def call(*args, **kwargs):
"""A central mechanism to call the main routine with the right parameters""" """A central mechanism to call the main routine with the right parameters"""
......
...@@ -37,22 +37,22 @@ ...@@ -37,22 +37,22 @@
# Basic tests for the command line beat program: config # Basic tests for the command line beat program: config
import os import os
import shutil
import click import click
import nose.tools import nose.tools
import simplejson import simplejson
import shutil
from click.testing import CliRunner from click.testing import CliRunner
from beat.cmdline.scripts import main_cli
from beat.core.plotter import Storage as PStorage from beat.core.plotter import Storage as PStorage
from beat.core.test.utils import cleanup from beat.core.test.utils import cleanup
from beat.cmdline.scripts import main_cli
from .. import config
from .. import common from .. import common
from .. import config
from . import tmp_prefix, temp_cwd from . import temp_cwd
from . import tmp_prefix
def call(*args, **kwargs): def call(*args, **kwargs):
......
...@@ -39,13 +39,15 @@ ...@@ -39,13 +39,15 @@
import nose import nose
import nose.tools import nose.tools
from beat.backend.python.test.test_database import INTEGERS_DBS
from beat.backend.python.protocoltemplate import Storage as PTStorage from beat.backend.python.protocoltemplate import Storage as PTStorage
from beat.backend.python.test.test_database import INTEGERS_DBS
from beat.core.database import Storage, Database, get_first_procotol_template 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 core
from . import prefix, tmp_prefix from . import prefix
from . import tmp_prefix
class TestLocal(core.AssetLocalTest): class TestLocal(core.AssetLocalTest):
......
...@@ -36,10 +36,12 @@ ...@@ -36,10 +36,12 @@
# Basic tests for the command line beat program: dataformats # 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 core
from . import tmp_prefix, prefix from . import prefix
from . import tmp_prefix
class TestOnline(core.OnlineAssetTestCase): class TestOnline(core.OnlineAssetTestCase):
......
...@@ -36,20 +36,21 @@ ...@@ -36,20 +36,21 @@
# Docker based tests for algorithms and analyzers # Docker based tests for algorithms and analyzers
import os
import json import json
import os
import shutil import shutil
import pkg_resources
from beat.core.test.utils import slow
import nose.tools import nose.tools
import pkg_resources
from beat.backend.python.hash import hashDataset from beat.backend.python.hash import hashDataset
from beat.backend.python.hash import toPath from beat.backend.python.hash import toPath
from beat.core.database import Database from beat.core.database import Database
from beat.core.test.utils import slow
from . import core from . import core
from . import prefix, tmp_prefix from . import prefix
from . import tmp_prefix
instructions_dir = pkg_resources.resource_filename(__name__, "instructions") instructions_dir = pkg_resources.resource_filename(__name__, "instructions")
......
...@@ -36,11 +36,12 @@ ...@@ -36,11 +36,12 @@
# Basic tests for the command line beat program: protocoltemplates # 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 Library
from beat.core.library import Storage
from . import core from . import core
from . import tmp_prefix, prefix from . import prefix
from . import tmp_prefix
class TestLocal(core.AssetLocalTest): class TestLocal(core.AssetLocalTest):
......
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
import nose.tools 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 beat.core.test.utils import slow
from . import core from . import core
......
...@@ -36,13 +36,15 @@ ...@@ -36,13 +36,15 @@
# Basic tests for the command line beat program: plotters # Basic tests for the command line beat program: plotters
import collections
import os import os
import nose.tools import nose.tools
import simplejson 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.test.utils import slow
from beat.core.plotter import Storage, Plotter
from . import core from . import core
from . import tmp_prefix from . import tmp_prefix
......
...@@ -36,24 +36,29 @@ ...@@ -36,24 +36,29 @@
import difflib import difflib
import nose.tools
def test_shortcuts(): def test_shortcuts():
shortcuts = { shortcuts = {
'c': 'config', "c": "config",
'co': 'config', "co": "config",
'cf': 'config', "cf": "config",
'st': 'status', "st": "status",
's': 'status', "s": "status",
'db': 'databases', "db": "databases",
'df': 'dataformats', "df": "dataformats",
'lib': 'libraries', "lib": "libraries",
'l': 'libraries', "l": "libraries",
'algo': 'algorithms', "algo": "algorithms",
'al': 'algorithms', "al": "algorithms",
'tc': 'toolchains', "tc": "toolchains",
'exp': 'experiments', "exp": "experiments",
'xp': 'experiments', "xp": "experiments",
} }
for k, v in shortcuts.items(): for k, v in shortcuts.items():
cmd = difflib.get_close_matches(k, set(shortcuts.values()), cutoff=0.2) 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]) nose.tools.assert_true(
len(cmd) > 0 and cmd[0] == v, "`%s' != `%s' (%s)" % (k, v, cmd[0])
)
...@@ -37,9 +37,11 @@ ...@@ -37,9 +37,11 @@
# Basic tests for the command line beat program: toolchains # Basic tests for the command line beat program: toolchains
import os import os
import nose.tools 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 core
from . import tmp_prefix from . import tmp_prefix
......
...@@ -37,20 +37,24 @@ ...@@ -37,20 +37,24 @@
Helper functions to run tests Helper functions to run tests
""" """
import os
import logging import logging
import pdb import os
import pdb # noqa
import sys import sys
from beat.core.experiment import Experiment from beat.core.experiment import Experiment
from beat.core.hash import toPath
from beat.core.hash import hashDataset 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(): 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): def index_experiment_dbs(experiment_name):
""" """
...@@ -59,14 +63,19 @@ def index_experiment_dbs(experiment_name): ...@@ -59,14 +63,19 @@ def index_experiment_dbs(experiment_name):
experiment = Experiment(prefix, 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(): for block_name, infos in experiment.datasets.items():
view = infos['database'].view(infos['protocol'], infos['set']) view = infos["database"].view(infos["protocol"], infos["set"])
filename = toPath(hashDataset(infos['database'].name, filename = toPath(
infos['protocol'], hashDataset(infos["database"].name, infos["protocol"], infos["set"]),
infos['set']), suffix=".db",
suffix='.db') )
view.index(os.path.join(tmp_prefix, filename)) view.index(os.path.join(tmp_prefix, filename))
...@@ -80,9 +89,12 @@ class MockLoggingHandler(logging.Handler): ...@@ -80,9 +89,12 @@ class MockLoggingHandler(logging.Handler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.messages = { self.messages = {
'debug': [], 'info': [], "debug": [],
'warning': [], 'error': [], "info": [],
'critical': [], 'extra': [] "warning": [],
"error": [],
"critical": [],
"extra": [],
} }
super(MockLoggingHandler, self).__init__(*args, **kwargs) super(MockLoggingHandler, self).__init__(*args, **kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment