Exemplo n.º 1
0
def test_create_many():
    tmp_dir = scratch_path / "create_many"
    dmf = DMF(path=tmp_dir, create=True)
    for i in range(100):
        exp = experiment.Experiment(dmf, name="try{i}".format(i=i))
        assert exp.name == "try{i}".format(i=i)
        assert exp.id
Exemplo n.º 2
0
def test_relation_in_experiment():
    tmp_dir = scratch_path / "relation_in_experiment"
    dmf = DMF(path=tmp_dir, create=True)
    e1 = experiment.Experiment(dmf, name="1")
    a = resource.Resource(value={"name": "foo"})
    e1.add(a)
    assert len(a.v["relations"]) == 1
    assert len(e1.v["relations"]) == 1
Exemplo n.º 3
0
def test_relation_with_remove(tmp_dmf):
    e1 = experiment.Experiment(tmp_dmf, name="1")
    n, added = 10, []
    for i in range(n):
        a = resource.Resource({"name": "foo"})
        e1.add(a)
        added.append(a)
    assert len(e1.v["relations"]) == n
    # remove, then update e1
    for a in added:
        tmp_dmf.remove(identifier=a.id)
        e1.update()
        # relation to removed 'a' should be gone
        n -= 1
        assert (len(e1.v["relations"])) == n
Exemplo n.º 4
0
def test_relation_with_remove():
    tmp_dir = scratch_path / "relation_with_remove"
    dmf = DMF(path=tmp_dir, create=True)
    e1 = experiment.Experiment(dmf, name="1")
    n, added = 10, []
    for i in range(n):
        a = resource.Resource({"name": "foo"})
        e1.add(a)
        added.append(a)
    assert len(e1.v["relations"]) == n
    # remove, then update e1
    for a in added:
        dmf.remove(identifier=a.id)
        e1.update()
        # relation to removed 'a' should be gone
        n -= 1
        assert (len(e1.v["relations"])) == n
Exemplo n.º 5
0
def test_remove_workflow(tmp_dmf):
    # A workflow of copy/remove
    # make an experiment
    e1 = experiment.Experiment(tmp_dmf, name='one', version='0.0.1')
    # make a new version of it
    e2 = e1.copy(version='0.0.2')
    # link the two together
    e1.link(e2, predicate=resource.PR_VERSION)
    # remove the first one (what happens to the link?)
    e1.remove()
    # check that the first one can't be used any more
    with pytest.raises(errors.BadResourceError):
        e1.update()
    with pytest.raises(errors.BadResourceError):
        e1.link(e2, predicate=resource.PR_VERSION)
    # check that the copy can still be modified
    e2.v['desc'] = 'This is a copy of e1'
    e2.update()  # this fixes relations in the DB
    # check that the link is gone, i.e. there are no
    # relations in e2 any more
    assert len(e2.v['relations']) == 0
Exemplo n.º 6
0
def test_remove_workflow():
    tmp_dir = scratch_path / "remove_workflow"
    dmf = DMF(path=tmp_dir, create=True)
    # A workflow of copy/remove
    # make an experiment
    e1 = experiment.Experiment(dmf, name="one", version="0.0.1")
    # make a new version of it
    e2 = e1.copy(version="0.0.2")
    # link the two together
    e1.link(e2, predicate=Predicates.version)
    # remove the first one (what happens to the link?)
    e1.remove()
    # check that the first one can't be used any more
    with pytest.raises(errors.BadResourceError):
        e1.update()
    with pytest.raises(errors.BadResourceError):
        e1.link(e2, predicate=Predicates.version)
    # check that the copy can still be modified
    e2.v["desc"] = "This is a copy of e1"
    e2.update()  # this fixes relations in the DB
    # check that the link is gone, i.e. there are no
    # relations in e2 any more
    assert len(e2.v["relations"]) == 0
Exemplo n.º 7
0
def test_relation_in_experiment(tmp_dmf):
    e1 = experiment.Experiment(tmp_dmf, name="1")
    a = resource.Resource(value={"name": "foo"})
    e1.add(a)
    assert len(a.v["relations"]) == 1
    assert len(e1.v["relations"]) == 1
Exemplo n.º 8
0
def test_create_many(tmp_dmf):
    for i in range(100):
        exp = experiment.Experiment(tmp_dmf, name='try{i}'.format(i=i))
        assert exp.v['name'] == 'try{i}'.format(i=i)
        assert exp.id
Exemplo n.º 9
0
def test_init(tmp_dmf):
    exp = experiment.Experiment(tmp_dmf, name='try1', desc='Nice try')
    assert exp.v['name'] == 'try1'
    assert exp.id
Exemplo n.º 10
0
def test_create_many(tmp_dmf):
    for i in range(100):
        exp = experiment.Experiment(tmp_dmf, name="try{i}".format(i=i))
        assert exp.v["name"] == "try{i}".format(i=i)
        assert exp.id
Exemplo n.º 11
0
def test_init(tmp_dmf):
    exp = experiment.Experiment(tmp_dmf, name="try1", desc="Nice try")
    assert exp.v["name"] == "try1"
    assert exp.id
Exemplo n.º 12
0
def test_relation_in_experiment(tmp_dmf):
    e1 = experiment.Experiment(tmp_dmf, name='1')
    a = resource.Resource(value={'name': 'foo'})
    e1.add(a)
    assert len(a.v['relations']) == 1
    assert len(e1.v['relations']) == 1
Exemplo n.º 13
0
def test_init():
    tmp_dir = scratch_path / "init"
    dmf = DMF(path=tmp_dir, create=True)
    exp = experiment.Experiment(dmf, name="try1", desc="Nice try")
    assert exp.name == "try1"
    assert exp.id