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

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

parent f02299b6
......@@ -38,68 +38,33 @@
import os
import nose.tools
import click
from click.testing import CliRunner
from beat.core.plotterparameter import Storage
from beat.core.test.utils import slow, cleanup, skipif
from beat.cmdline.scripts import main_cli
from beat.core.test.utils import slow
from . import core
from . import platform, disconnected, prefix, tmp_prefix, user, token
from . import tmp_prefix
def call(*args, **kwargs):
"""A central mechanism to call the main routine with the right parameters"""
class TestOnlinePlotterParameters(core.OnlineAssetTestCase):
use_prefix = kwargs.get("prefix", prefix)
use_platform = kwargs.get("platform", platform)
use_cache = kwargs.get("cache", "cache")
asset_type = "plotterparameters"
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(
main_cli.main,
[
"--test-mode",
"--platform",
use_platform,
"--prefix",
use_prefix,
"--token",
token,
"--user",
user,
"--cache",
use_cache,
"plotterparameters",
]
+ list(args),
catch_exceptions=False,
@slow
@core.skip_disconnected
def test_pull_one(self, obj=None):
obj = obj or "plot/bar/1"
exit_code, output = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
nose.tools.assert_true(
os.path.exists(os.path.join(tmp_prefix, "plotterparameters", obj + ".json"))
)
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_pull_one(obj=None):
obj = obj or "plot/bar/1"
nose.tools.eq_(call("pull", obj, prefix=tmp_prefix), 0)
nose.tools.assert_true(
os.path.exists(os.path.join(tmp_prefix, "plotterparameters", obj + ".json"))
)
@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
@core.skip_disconnected
def test_pull_all(self):
exit_code, output = self.call("pull", prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
class TestPlotterparameterLocal(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