Example #1
0
def test_docnetdb_load_place_reset(tmp_path):
    """Test if the DocNetDB load with a blank file reset _next_place."""
    db = DocNetDB(tmp_path / "db1.db")
    for __ in range(3):
        db.insert(Vertex())
    db.save()

    db.path = tmp_path / "db2.db"
    db.load()
    assert db.insert(Vertex()) == 1
Example #2
0
def test_docnetdb_load_no_duplication(tmp_path):
    """Test if calling DocNetDB load two times doesn't duplicate anything.

    Like the vertices or the edges.
    """
    path = tmp_path / "db.db"
    db1 = DocNetDB(path)
    v1, v2 = Vertex(), Vertex()
    db1.insert(v1)
    db1.insert(v2)
    db1.insert_edge(Edge(v1, v2, "my_edge", True))
    db1.save()

    # The file is loaded into the same database.
    db1.load()

    assert len(db1) == 2
    assert len(list(db1.search_edge(db1[1]))) == 1