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

[test] Refactor tests for centralized diff and status tests

parent 5825cdd8
......@@ -50,30 +50,14 @@ class TestOnlinAlgorithms(core.OnlineAssetTestCase):
asset_type = "algorithm"
storage_cls = Storage
object_map = {"pull": "user/integers_add/1"}
object_map = {"pull": "user/integers_add/1", "diff": "user/integers_add/1"}
@slow
@core.skip_disconnected
def test_diff(self):
obj = "user/integers_add/1"
exit_code, outputs = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
def _modify_asset(self, asset_name):
"""Re-imp"""
# quickly modify the user algorithm by emptying it
storage = Storage(tmp_prefix, obj)
storage = self.storage_cls(tmp_prefix, asset_name)
storage.code.save("class Algorithm:\n pass")
exit_code, outputs = self.call("diff", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
@slow
@core.skip_disconnected
def test_status(self):
self.test_diff()
self.test_pull_one()
exit_code, outputs = self.call("status", prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
def create_dataformat(self):
obj = "user/integers/1"
......
......@@ -41,7 +41,6 @@ import nose.tools
from beat.backend.python.test.test_database import INTEGERS_DBS
from beat.backend.python.protocoltemplate import Storage as PTStorage
from beat.core.test.utils import slow
from beat.core.database import Storage, Database, get_first_procotol_template
from . import core
......@@ -72,32 +71,19 @@ class TestDatabaseLocal(core.AssetLocalTest):
class TestOnlinDatabases(core.OnlineAssetTestCase):
asset_type = "database"
storage_cls = Storage
object_map = {"pull": "simple/1"}
object_map = {"pull": "simple/1", "diff": "simple/1"}
@slow
@core.skip_disconnected
def test_diff(self):
obj = "simple/1"
exit_code, outputs = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
def _modify_asset(self, asset_name):
"""Re-imp"""
# quickly modify the user algorithm by emptying it
f = Database(tmp_prefix, obj)
database = Database(tmp_prefix, asset_name)
nose.tools.eq_(
len(f.errors), 0, "Failed to load Database: \n%s" % "\n".join(f.errors)
len(database.errors),
0,
"Failed to load Database: \n%s" % "\n".join(database.errors),
)
f.data["root_folder"] = "/a/different/path"
f.write()
exit_code, outputs = self.call("diff", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
@slow
@core.skip_disconnected
def test_status(self):
self.test_diff()
exit_code, outputs = self.call("status", prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
database.data["root_folder"] = "/a/different/path"
database.write()
class TestView(core.AssetBaseTest):
......
......@@ -49,30 +49,14 @@ class TestOnlineDataformats(core.OnlineAssetTestCase):
asset_type = "dataformat"
storage_cls = Storage
object_map = {"pull": "system/bounding_box_video/1"}
object_map = {"pull": "system/bounding_box_video/1", "diff": "system/integer/1"}
@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)
def _modify_asset(self, asset_name):
"""Re-imp"""
# 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)
dataformat = DataFormat(tmp_prefix, asset_name)
dataformat.data["value"] = "int64"
dataformat.write()
@slow
@core.skip_disconnected
......
......@@ -63,33 +63,17 @@ class TestOnlineExperiments(core.OnlineAssetTestCase):
asset_type = "experiment"
storage_cls = Storage
object_map = {"pull": "user/user/single/1/single"}
object_map = {
"pull": "user/user/single/1/single",
"diff": "user/user/single/1/single",
}
@slow
@core.skip_disconnected
def test_diff(self):
obj = "user/user/single/1/single"
exit_code, outputs = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
s = Storage(tmp_prefix, obj)
nose.tools.assert_true(s.exists())
def _modify_asset(self, asset_name):
"""Re-imp"""
# quickly modify the user experiment:
f = Experiment(tmp_prefix, obj)
f.data["globals"]["queue"] = "another_queue"
f.write()
exit_code, outputs = self.call("diff", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
@slow
@core.skip_disconnected
def test_status(self):
self.test_diff()
self.test_pull_one()
exit_code, outputs = self.call("status", prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, outputs)
experiment = Experiment(tmp_prefix, asset_name)
experiment.data["globals"]["queue"] = "another_queue"
experiment.write()
@core.skip_disconnected
def test_fork(self, obj=None, obj2=None):
......
......@@ -62,30 +62,14 @@ class TestOnlineLibraries(core.OnlineAssetTestCase):
asset_type = "library"
storage_cls = Storage
object_map = {"pull": "plot/baselib/1"}
object_map = {"pull": "plot/baselib/1", "diff": "plot/baselib/1"}
@slow
@core.skip_disconnected
def test_diff(self):
obj = "plot/baselib/1"
exit_code, output = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
def _modify_asset(self, asset_name):
"""Re-imp"""
# quickly modify the user library by emptying it
storage = Storage(tmp_prefix, obj)
storage = self.storage_cls(tmp_prefix, asset_name)
storage.code.save("class Dummy:\n pass")
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):
......
......@@ -36,16 +36,24 @@
# Basic tests for the command line beat program: plotterparameters
from beat.core.plotterparameter import Storage
from beat.core.plotterparameter import Storage, Plotterparameter
from . import core
from . import tmp_prefix
class TestOnlinePlotterParameters(core.OnlineAssetTestCase):
asset_type = "plotterparameters"
asset_type = "plotterparameter"
storage_cls = Storage
object_map = {"pull": "plot/bar/1"}
object_map = {"pull": "plot/bar/1", "diff": "plot/bar/1"}
def _modify_asset(self, asset_name):
"""Re-imp"""
plotterparameter = Plotterparameter(tmp_prefix, asset_name)
plotterparameter.data["value"] = {"dummy": "int64"}
plotterparameter.write()
class TestPlotterparameterLocal(core.AssetLocalTest):
......
......@@ -42,7 +42,7 @@ import simplejson
import collections
from beat.core.test.utils import slow
from beat.core.plotter import Storage
from beat.core.plotter import Storage, Plotter
from . import core
from . import tmp_prefix
......@@ -52,7 +52,14 @@ class TestOnlinePlotters(core.OnlineAssetTestCase):
asset_type = "plotter"
storage_cls = Storage
object_map = {"pull": "plot/bar/1"}
object_map = {"pull": "plot/bar/1", "diff": "plot/bar/1"}
def _modify_asset(self, asset_name):
"""Re-imp"""
plotter = Plotter(tmp_prefix, asset_name)
plotter.data["language"] = "cxx"
plotter.write()
@slow
@core.skip_disconnected
......
......@@ -39,7 +39,6 @@
import os
import nose.tools
from beat.core.test.utils import slow
from beat.core.toolchain import Storage, Toolchain
from . import core
......@@ -50,30 +49,14 @@ class TestOnlineToolchains(core.OnlineAssetTestCase):
asset_type = "toolchain"
storage_cls = Storage
object_map = {"pull": "user/single/1"}
object_map = {"pull": "user/single/1", "diff": "user/single/1"}
@slow
@core.skip_disconnected
def test_diff(self):
obj = "user/single/1"
exit_code, output = self.call("pull", obj, prefix=tmp_prefix)
nose.tools.eq_(exit_code, 0, output)
def _modify_asset(self, asset_name):
"""Re-imp"""
# quickly modify the user toolchain:
f = Toolchain(tmp_prefix, obj)
f.data["representation"]["blocks"]["echo"]["height"] = 2
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)
toolchains = Toolchain(tmp_prefix, asset_name)
toolchains.data["representation"]["blocks"]["echo"]["height"] = 2
toolchains.write()
@core.skip_disconnected
def test_push_and_delete(self):
......
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