Skip to content

Commit

Permalink
tests: add tests for fuzzy search on multiple model attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Nov 21, 2023
1 parent 2317209 commit 8b3802d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/backends/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_model_indexation(testclient, backend):
assert not models.User.get(emails=["[email protected]"])


def test_fuzzy(user, moderator, admin, backend):
def test_fuzzy_unique_attribute(user, moderator, admin, backend):
assert set(models.User.query()) == {user, moderator, admin}
assert set(models.User.fuzzy("Jack")) == {moderator}
assert set(models.User.fuzzy("Jack", ["formatted_name"])) == {moderator}
Expand All @@ -177,7 +177,18 @@ def test_fuzzy(user, moderator, admin, backend):
assert set(models.User.fuzzy("ack")) == {moderator}


# def test_model_references(user, admin, foo_group, bar_group):
def test_fuzzy_multiple_attribute(user, moderator, admin, backend):
assert set(models.User.query()) == {user, moderator, admin}
assert set(models.User.fuzzy("[email protected]")) == {moderator}
assert set(models.User.fuzzy("[email protected]", ["emails"])) == {moderator}
assert set(models.User.fuzzy("[email protected]", ["formatted_name"])) == set()
assert set(models.User.fuzzy("[email protected]", ["emails", "formatted_name"])) == {
moderator
}
assert set(models.User.fuzzy("[email protected]")) == {moderator}
assert set(models.User.fuzzy("doe.com")) == {user, moderator, admin}


def test_model_references(testclient, user, foo_group, admin, bar_group, backend):
# assert foo_group.members == [user]
# assert user.groups == [foo_group]
Expand Down

0 comments on commit 8b3802d

Please sign in to comment.