Commit 53f7b617 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

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

parent eedcaa07
......@@ -39,80 +39,47 @@
import nose.tools
import simplejson as json
from click.testing import CliRunner
from beat.core.test.utils import slow
from beat.core.test.utils import slow, cleanup, skipif
from . import core
from beat.cmdline.scripts import main_cli
from . import platform, disconnected, prefix, user, token
class TestOnlineEnvironments(core.OnlineTestCase):
asset_type = "environments" # give command group as environments are not assets
@slow
@core.skip_disconnected
def test_all_list(self):
exit_code, output = self.call("list", "-t", "all")
nose.tools.eq_(exit_code, 0, msg=output)
def call(*args, **kwargs):
"""A central mechanism to call the main routine with the right parameters"""
output_data = json.loads(output)
use_prefix = kwargs.get("prefix", prefix)
use_platform = kwargs.get("platform", platform)
use_cache = kwargs.get("cache", "cache")
nose.tools.assert_true(all(key in output_data for key in ["remote", "docker"]))
nose.tools.assert_not_equals(len(output_data["remote"]), 0)
nose.tools.assert_not_equals(len(output_data["docker"]), 0)
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(
main_cli.main,
[
"--platform",
use_platform,
"--user",
user,
"--token",
token,
"--prefix",
use_prefix,
"--cache",
use_cache,
"--test-mode",
"environments",
]
+ list(args),
catch_exceptions=False,
)
return result.exit_code, result.output
@slow
@core.skip_disconnected
def test_remote_list(self):
exit_code, output = self.call("list", "-t", "remote")
nose.tools.eq_(exit_code, 0, msg=output)
output_data = json.loads(output)
@slow
@nose.tools.with_setup(teardown=cleanup)
@skipif(disconnected, "missing test platform (%s)" % platform)
def test_all_list():
exit_code, output = call("list", "-t", "all")
nose.tools.eq_(exit_code, 0, msg=output)
nose.tools.assert_true("remote" in output_data)
nose.tools.assert_not_equals(len(output_data["remote"]), 0)
output_data = json.loads(output)
nose.tools.assert_true(all(key in output_data for key in ["remote", "docker"]))
nose.tools.assert_not_equals(len(output_data["remote"]), 0)
nose.tools.assert_not_equals(len(output_data["docker"]), 0)
class TestDockerEnvironments(core.AssetBaseTest):
asset_type = "environments" # give command group as environments are not assets
@slow
def test_docker_list(self):
exit_code, output = self.call("list", "-t", "docker")
nose.tools.eq_(exit_code, 0, msg=output)
@slow
@nose.tools.with_setup(teardown=cleanup)
@skipif(disconnected, "missing test platform (%s)" % platform)
def test_remote_list():
exit_code, output = call("list", "-t", "remote")
nose.tools.eq_(exit_code, 0, msg=output)
output_data = json.loads(output)
output_data = json.loads(output)
nose.tools.assert_true("remote" in output_data)
nose.tools.assert_not_equals(len(output_data["remote"]), 0)
@slow
@nose.tools.with_setup(teardown=cleanup)
def test_docker_list():
exit_code, output = call("list", "-t", "docker")
nose.tools.eq_(exit_code, 0, msg=output)
output_data = json.loads(output)
nose.tools.assert_true("docker" in output_data)
nose.tools.assert_not_equals(len(output_data["docker"]), 0)
nose.tools.assert_true("docker" in output_data)
nose.tools.assert_not_equals(len(output_data["docker"]), 0)
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