Skip to content

Commit

Permalink
Working unit test for clearing the databasE
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Langdale committed Oct 21, 2024
1 parent e076fee commit a121aae
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions test/server/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from matchbox.server import MatchboxDBAdapter
from matchbox.server.base import MatchboxModelAdapter
from matchbox.server.models import Cluster, Probability, Source
from matchbox.server.postgresql import MatchboxPostgres
from pandas import DataFrame

from ..fixtures.db import (
Expand Down Expand Up @@ -815,6 +814,43 @@ def test_properties(
assert isinstance(backend.proposes.count(), int)


def test_clear(matchbox_postgres: MatchboxPostgres):
@pytest.mark.parametrize("backend", backends)
def test_clear(
backend: MatchboxDBAdapter,
db_add_dedupe_models_and_data: AddDedupeModelsAndDataCallable,
db_add_indexed_data: AddIndexedDataCallable,
warehouse_data: list[Source],
request: pytest.FixtureRequest,
):
"""Test clearing the database."""
pass
backend = request.getfixturevalue(backend)

# Setup
db_add_dedupe_models_and_data(
db_add_indexed_data=db_add_indexed_data,
backend=backend,
warehouse_data=warehouse_data,
dedupe_data=dedupe_data_test_params,
dedupe_models=[dedupe_model_test_params[0]], # Naive deduper,
request=request,
)

# Test

assert backend.datasets.count() > 0
assert backend.data.count() > 0
assert backend.models.count() > 0
assert backend.clusters.count() > 0
assert backend.creates.count() > 0
assert backend.merges.count() > 0
assert backend.proposes.count() > 0

backend.clear(certain=True)

assert backend.datasets.count() == 0
assert backend.data.count() == 0
assert backend.models.count() == 0
assert backend.clusters.count() == 0
assert backend.creates.count() == 0
assert backend.merges.count() == 0
assert backend.proposes.count() == 0

0 comments on commit a121aae

Please sign in to comment.