Commit c5cf281b authored by André Anjos's avatar André Anjos 💬

Merge branch 'fix_tests' into 'master'

Fix tests

See merge request !61
parents b6dabb21 7eede766
Pipeline #27602 passed with stages
in 10 minutes and 19 seconds
......@@ -35,11 +35,24 @@ from click.testing import CliRunner
import shutil
import json
from . import platform, disconnected, prefix, tmp_prefix, user, token, temp_cwd
from ..common import Selector
from beat.cmdline.scripts import main_cli
from beat.core.test.utils import slow, cleanup, skipif
from beat.core.algorithm import Storage
from beat.cmdline.scripts import main_cli
from .. import common
from . import platform, disconnected, prefix, tmp_prefix, user, token, temp_cwd
def setup():
"""Create default dataformat for algorithm prototype loading"""
from .test_dataformats import test_create as df_test_create
from .test_dataformats import call as df_call
obj = 'user/integers/1'
nose.tools.eq_(df_call('create', obj, prefix=tmp_prefix), 0)
nose.tools.eq_(df_call('push', obj, prefix=tmp_prefix), 0)
def call(*args, **kwargs):
......@@ -55,7 +68,8 @@ def call(*args, **kwargs):
main_cli.main,
['--platform', use_platform, '--user', user, '--token', token,
'--prefix', use_prefix, '--cache', use_cache, '--test-mode',
'algorithms'] + list(args)
'algorithms'] + list(args),
catch_exceptions=False
)
return result.exit_code, result.output
......@@ -131,7 +145,7 @@ def test_check_invalid():
nose.tools.eq_(exit_code, 1, outputs)
@nose.tools.with_setup(teardown=cleanup)
@nose.tools.with_setup(setup=setup, teardown=cleanup)
def test_create(obj=None):
obj = obj or 'legacy/algorithm/1'
exit_code, outputs = call('create', obj, prefix=tmp_prefix)
......@@ -141,7 +155,7 @@ def test_create(obj=None):
return s
@nose.tools.with_setup(teardown=cleanup)
@nose.tools.with_setup(setup=setup, teardown=cleanup)
def test_new_version():
obj = 'legacy/algorithm/1'
test_create(obj)
......@@ -152,11 +166,11 @@ def test_new_version():
assert s.exists()
# check version status
with Selector(tmp_prefix) as selector:
with common.Selector(tmp_prefix) as selector:
assert selector.version_of('algorithm', obj2) == obj
@nose.tools.with_setup(teardown=cleanup)
@nose.tools.with_setup(setup=setup, teardown=cleanup)
def test_fork():
obj = 'legacy/algorithm/1'
test_create(obj)
......@@ -167,11 +181,11 @@ def test_fork():
assert s.exists()
# check fork status
with Selector(tmp_prefix) as selector:
with common.Selector(tmp_prefix) as selector:
assert selector.forked_from('algorithm', obj2) == obj
@nose.tools.with_setup(teardown=cleanup)
@nose.tools.with_setup(setup=setup, teardown=cleanup)
def test_delete_local():
obj = 'legacy/algorithm/1'
storage = test_create(obj)
......@@ -185,7 +199,7 @@ def test_delete_local():
assert not storage.exists()
@nose.tools.with_setup(teardown=cleanup)
@nose.tools.with_setup(setup=setup, teardown=cleanup)
@skipif(disconnected, "missing test platform (%s)" % platform)
def test_push_and_delete():
obj = 'user/newobject/1'
......
......@@ -121,13 +121,13 @@ def test_set_get_local_atnt_db():
@nose.tools.with_setup(teardown=cleanup)
def test_set_bad_config_key():
db_config = 'fail'
nose.tools.eq_(call('config', 'set', '--local', db_config, db_config), 1)
nose.tools.assert_not_equal(call('config', 'set', '--local', db_config, db_config), 0)
@nose.tools.with_setup(teardown=cleanup)
def test_get_bad_config_key():
db_config = 'fail'
nose.tools.eq_(call('config', 'get', db_config), 1)
nose.tools.assert_not_equal(call('config', 'get', db_config), 0)
@nose.tools.with_setup(teardown=cleanup)
......
......@@ -30,6 +30,8 @@ Helper functions to run tests
import os
import logging
import pdb
import sys
from beat.core.experiment import Experiment
from beat.core.hash import toPath
......@@ -38,6 +40,9 @@ from beat.core.hash import hashDataset
from . import prefix, tmp_prefix
def set_trace():
pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__).set_trace()
def index_experiment_dbs(experiment_name):
"""
Index all databases for given experiment
......
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