Commit ab70826e authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][dataformats] Refactor online tests to use new live server based test class

parent 3abb6dae
......@@ -37,104 +37,73 @@
# Basic tests for the command line beat program: dataformats
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.dataformat import Storage, DataFormat
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,
"dataformats",
]
+ 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 = "system/bounding_box_video/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 = "system/integer/1"
nose.tools.eq_(call("pull", obj, prefix=tmp_prefix), 0)
# quickly modify the user dataformat by emptying it
f = DataFormat(tmp_prefix, obj)
f.data["value"] = "int64"
f.write()
nose.tools.eq_(call("diff", obj, prefix=tmp_prefix), 0)
@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"
TestDataFormatLocal.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)
from . import tmp_prefix
class TestOnlineDataformats(core.OnlineAssetTestCase):
asset_type = "dataformat"
@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 = "system/bounding_box_video/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 = "system/integer/1"
exit_code, output = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
# quickly modify the user dataformat by emptying it
f = DataFormat(tmp_prefix, obj)
f.data["value"] = "int64"
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)
@slow
@core.skip_disconnected
def test_push_and_delete(self):
obj = "user/newobject/1"
TestDataFormatLocal.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)
class TestDataFormatLocal(core.AssetLocalTest):
......
Supports Markdown
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