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

[test][test_experiment_loading] Code cleanup

parent 0f25f17e
......@@ -46,85 +46,95 @@ def test_load_valid_experiment():
experiment = Experiment(prefix, "user/integers_addition/1/integers_addition")
assert experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
nose.tools.assert_true(
experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
)
nose.tools.eq_(experiment.label, "user/user/integers_addition/1/integers_addition")
assert experiment.toolchain.valid, "\n * %s" % "\n * ".join(
experiment.toolchain.errors
nose.tools.assert_true(
experiment.toolchain.valid,
"\n * %s" % "\n * ".join(experiment.toolchain.errors),
)
nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/1")
nose.tools.eq_(len(experiment.datasets), 1)
assert "integers" in experiment.datasets
nose.tools.assert_true("integers" in experiment.datasets)
nose.tools.eq_(len(experiment.databases), 1)
nose.tools.eq_(len(experiment.blocks), 1)
nose.tools.eq_(len(experiment.analyzers), 1)
nose.tools.eq_(len(experiment.algorithms), 2)
assert "user/sum/1" in experiment.algorithms
assert experiment.algorithms["user/sum/1"].valid
assert "user/integers_analysis/1" in experiment.algorithms
assert experiment.algorithms["user/integers_analysis/1"].valid
nose.tools.assert_true("user/sum/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
def test_load_one_dataset_two_blocks_toolchain():
experiment = Experiment(prefix, "user/integers_addition/2/integers_addition")
assert experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
nose.tools.assert_true(
experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
)
nose.tools.eq_(experiment.label, "user/user/integers_addition/2/integers_addition")
assert experiment.toolchain.valid, "\n * %s" % "\n * ".join(
experiment.toolchain.errors
nose.tools.assert_true(
experiment.toolchain.valid,
"\n * %s" % "\n * ".join(experiment.toolchain.errors),
)
nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/2")
nose.tools.eq_(len(experiment.datasets), 1)
assert "integers" in experiment.datasets
nose.tools.assert_true("integers" in experiment.datasets)
nose.tools.eq_(len(experiment.databases), 1)
nose.tools.eq_(len(experiment.blocks), 2)
nose.tools.eq_(len(experiment.analyzers), 1)
nose.tools.eq_(len(experiment.algorithms), 2)
assert "user/sum/1" in experiment.algorithms
assert experiment.algorithms["user/sum/1"].valid
assert "user/integers_analysis/1" in experiment.algorithms
assert experiment.algorithms["user/integers_analysis/1"].valid
nose.tools.assert_true("user/sum/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
def test_load_two_datasets_three_blocks_toolchain():
experiment = Experiment(prefix, "user/integers_addition/3/integers_addition")
assert not experiment.valid
nose.tools.assert_false(experiment.valid)
nose.tools.eq_(experiment.label, "user/user/integers_addition/3/integers_addition")
assert experiment.errors[0].find("mismatch in input/output") != -1
nose.tools.assert_not_equal(
experiment.errors[0].find("mismatch in input/output"), -1
)
assert experiment.toolchain.valid
nose.tools.assert_true(experiment.toolchain.valid)
nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/3")
nose.tools.eq_(len(experiment.datasets), 2)
assert "integers1" in experiment.datasets
assert "integers2" in experiment.datasets
nose.tools.assert_true("integers1" in experiment.datasets)
nose.tools.assert_true("integers2" in experiment.datasets)
nose.tools.eq_(len(experiment.databases), 1)
nose.tools.eq_(len(experiment.blocks), 3)
nose.tools.eq_(len(experiment.analyzers), 1)
nose.tools.eq_(len(experiment.algorithms), 2)
assert "user/sum/1" in experiment.algorithms
assert experiment.algorithms["user/sum/1"].valid
assert "user/integers_analysis/1" in experiment.algorithms
assert experiment.algorithms["user/integers_analysis/1"].valid
nose.tools.assert_true("user/sum/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
def test_no_description():
experiment = Experiment(prefix, "user/integers_addition/1/integers_addition")
assert experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
assert experiment.description is None
assert experiment.documentation is None
nose.tools.assert_true(
experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
)
nose.tools.assert_is_none(experiment.description)
nose.tools.assert_is_none(experiment.documentation)
description = "This is my descriptor"
experiment.description = description
assert isinstance(experiment.description, six.string_types)
nose.tools.assert_true(isinstance(experiment.description, six.string_types))
nose.tools.eq_(experiment.description, description)
......@@ -133,10 +143,10 @@ def test_export():
name = "user/integers_addition/1/integers_addition"
obj = Experiment(prefix, name)
assert obj.valid, "\n * %s" % "\n * ".join(obj.errors)
nose.tools.assert_true(obj.valid, "\n * %s" % "\n * ".join(obj.errors))
obj.export(tmp_prefix)
# load from tmp_prefix and validates
exported = Experiment(tmp_prefix, name)
assert exported.valid, "\n * %s" % "\n * ".join(exported.errors)
nose.tools.assert_true(exported.valid, "\n * %s" % "\n * ".join(exported.errors))
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