Commit 1f76e259 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][core] Refactor to centralize push and delete test

parent dab89c78
......@@ -134,6 +134,18 @@ class BaseTest:
class AssetBaseTest(BaseTest):
"""Base class that ensures that the asset_type is set before calling click"""
object_map = {}
storage_cls = None
@classmethod
def create(cls, obj=None):
obj = obj or cls.object_map["create"]
exit_code, outputs = cls.call("create", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
storage = cls.storage_cls(tmp_prefix, obj)
nose.tools.assert_true(storage.exists())
return storage
@classmethod
def call(cls, *args, **kwargs):
nose.tools.assert_is_not_none(cls.asset_type, "Missing value for asset_type")
......@@ -141,8 +153,7 @@ class AssetBaseTest(BaseTest):
class AssetLocalTest(AssetBaseTest):
object_map = {}
storage_cls = None
"""Base class for local tests"""
def __init__(self):
super().__init__()
......@@ -161,15 +172,6 @@ class AssetLocalTest(AssetBaseTest):
exit_code, outputs = self.call("check", self.object_map["invalid"])
nose.tools.eq_(exit_code, 1, outputs)
@classmethod
def create(cls, obj=None):
obj = obj or cls.object_map["create"]
exit_code, outputs = cls.call("create", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
s = cls.storage_cls(tmp_prefix, obj)
nose.tools.assert_true(s.exists())
return s
def test_create(self, obj=None):
self.create(self.object_map["create"])
......@@ -220,13 +222,12 @@ class AssetLocalTest(AssetBaseTest):
class AssetRemoteTest(AssetBaseTest):
object_map = {}
storage_cls = None
asset_cls = None
"""Base class for remote tests"""
def __init__(self):
super().__init__()
nose.tools.assert_true(self.object_map)
nose.tools.assert_is_not_none(self.storage_cls)
def _modify_asset(self, asset_name):
"""Modify an asset"""
......@@ -275,6 +276,18 @@ class AssetRemoteTest(AssetBaseTest):
exit_code, output = self.call("status", prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
@slow
@skip_disconnected
def test_push_and_delete(self):
asset_name = self.object_map["create"]
self.create(asset_name)
# now push the new object and then delete it remotely
exit_code, output = self.call("push", asset_name, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
exit_code, output = self.call("rm", "--remote", asset_name, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
class OnlineTestMixin:
"""Mixin for using Django's live server"""
......
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