def test_artifacts(db: RunDBInterface): k1, u1, art1 = "k1", "u1", {"a": 1} db.store_artifact(k1, art1, u1) art = db.read_artifact(k1, u1) assert art1["a"] == art["a"], "get artifact" art = db.read_artifact(k1) assert art1["a"] == art["a"], "get latest artifact" prj = "p1" k2, u2, art2 = "k2", "u2", {"a": 2} db.store_artifact(k2, art2, u2, project=prj) k3, u3, art3 = "k3", "u3", {"a": 3} db.store_artifact(k3, art3, u3, project=prj) arts = db.list_artifacts(project=prj, tag="*") expected = 2 if isinstance(db, SQLDB) else 4 # FIXME assert expected == len(arts), "list artifacts length" assert {2, 3} == {a["a"] for a in arts}, "list artifact a" db.del_artifact(key=k1) with pytest.raises(sqldb.RunDBError): db.read_artifact(k1)
def test_artifacts(db: RunDBInterface): k1, u1, art1 = 'k1', 'u1', {'a': 1} db.store_artifact(k1, art1, u1) art = db.read_artifact(k1, u1) assert art1['a'] == art['a'], 'get artifact' art = db.read_artifact(k1) assert art1['a'] == art['a'], 'get latest artifact' prj = 'p1' k2, u2, art2 = 'k2', 'u2', {'a': 2} db.store_artifact(k2, art2, u2, project=prj) k3, u3, art3 = 'k3', 'u3', {'a': 3} db.store_artifact(k3, art3, u3, project=prj) arts = db.list_artifacts(project=prj, tag='*') expected = 2 if isinstance(db, SQLDB) else 4 # FIXME assert expected == len(arts), 'list artifacts length' assert {2, 3} == {a['a'] for a in arts}, 'list artifact a' db.del_artifact(key=k1) with pytest.raises(sqldb.RunDBError): db.read_artifact(k1)