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

[test][core] Refactor class hierarchy to use online test for functions unrelated to assets

parent d45c057e
......@@ -71,12 +71,9 @@ else:
skip_disconnected = skipif(disconnected, "missing test platform (%s)" % platform)
class AssetBaseTest:
class BaseTest:
asset_type = None
def __init__(self):
nose.tools.assert_true(self.asset_type, "Missing asset type")
def setUp(self):
pass
......@@ -105,33 +102,43 @@ class AssetBaseTest:
cmd_group = cls.get_cmd_group(asset_type)
parameters = [
"--test-mode",
"--prefix",
use_prefix,
"--token",
token,
"--user",
user,
"--cache",
use_cache,
"--platform",
use_platform,
]
if cmd_group:
parameters.append(cmd_group)
parameters += list(args)
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(
main_cli.main,
[
"--test-mode",
"--prefix",
use_prefix,
"--token",
token,
"--user",
user,
"--cache",
use_cache,
"--platform",
use_platform,
cmd_group,
]
+ list(args),
catch_exceptions=False,
)
result = runner.invoke(main_cli.main, parameters, catch_exceptions=False)
if result.exit_code != 0:
click.echo(result.output)
return result.exit_code, result.output
class AssetBaseTest(BaseTest):
"""Base class that ensures that the asset_type is set before calling click"""
@classmethod
def call(cls, *args, **kwargs):
nose.tools.assert_is_not_none(cls.asset_type, "Missing value for asset_type")
return super().call(*args, **kwargs)
class AssetLocalTest(AssetBaseTest):
object_map = {}
storage_cls = None
......@@ -210,8 +217,8 @@ class AssetLocalTest(AssetBaseTest):
nose.tools.assert_false(storage.exists())
class OnlineTestCase(LiveServerTestCase, AssetBaseTest):
"""Test case using django live server for test of remote functions"""
class OnlineTestMixin:
"""Mixin for using Django's live server"""
def setUp(self):
"""Cache a copy of the database to avoid the need to call make install
......@@ -236,3 +243,19 @@ class OnlineTestCase(LiveServerTestCase, AssetBaseTest):
kwargs["platform"] = cls.live_server_url
return super().call(*args, **kwargs)
class OnlineTestCase(LiveServerTestCase, OnlineTestMixin, BaseTest):
"""Test case using django live server for test of remote functions"""
def setUp(self):
for base in OnlineTestCase.__bases__:
base.setUp(self)
class OnlineAssetTestCase(LiveServerTestCase, OnlineTestMixin, AssetBaseTest):
"""Test case using django live server for asset related remote tests"""
def setUp(self):
for base in OnlineTestCase.__bases__:
base.setUp(self)
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