Skip to content

Commit

Permalink
Rename keyword module to query
Browse files Browse the repository at this point in the history
To avoid clash with the builtin.
  • Loading branch information
tugrulates committed Jun 25, 2024
1 parent dac5d75 commit 77eb9d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions contacts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rich.progress import Progress
from rich.table import Table

from contacts import contact, keyword
from contacts import contact, query
from contacts.address_book import AddressBook
from contacts.applescript_address_book import AppleScriptBasedAddressBook
from contacts.category import Category
Expand Down Expand Up @@ -107,7 +107,7 @@ def main(
console = Console(width=width, safe_box=safe_box)
with Progress(transient=True, console=console) as progress:
task = progress.add_task("Counting contacts")
keywords = keyword.prepare_keywords(keywords or [])
keywords = query.prepare_keywords(keywords or [])

address_book = get_address_book(
brief=not (detail or json or check or fix),
Expand Down
2 changes: 1 addition & 1 deletion contacts/keyword.py → contacts/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Keyword operations."""
"""Query operations."""

from functools import cache
from itertools import chain, combinations
Expand Down
22 changes: 11 additions & 11 deletions tests/test_keyword.py → tests/test_query.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Unittests for keyword."""
"""Unittests for query."""

import importlib

import pytest
from typer.testing import CliRunner

from contacts import config, keyword
from contacts import config, query

runner = CliRunner(mix_stderr=True)

Expand All @@ -15,25 +15,25 @@ def cfg(monkeypatch: pytest.MonkeyPatch) -> config.Config:
"""Initialize the test configuration."""
cfg = config.Config()
monkeypatch.setattr(config, "get_config", lambda: cfg)
importlib.reload(keyword)
importlib.reload(query)
return cfg


def test_prepare() -> None:
"""Test non-extended prepare."""
assert keyword.prepare_keywords(["amelia", "bob"]) == ["Amelia", "Bob"]
assert keyword.prepare_keywords(["bob", "amelia"]) == ["Amelia", "Bob"]
assert keyword.prepare_keywords(["carnival balloon"]) == ["Carnival Balloon"]
assert query.prepare_keywords(["amelia", "bob"]) == ["Amelia", "Bob"]
assert query.prepare_keywords(["bob", "amelia"]) == ["Amelia", "Bob"]
assert query.prepare_keywords(["carnival balloon"]) == ["Carnival Balloon"]


def test_prepare_romanize(cfg: config.Config) -> None:
"""Test non-extended prepare."""
cfg.romanize = "öøÑ"
assert keyword.romanization() == {"n": ["ñ"], "o": ["ö", "ø"]}
assert set(keyword.prepare_keywords(["BOB"])) == {"Bob", "Böb", "Bøb"}
assert set(keyword.prepare_keywords(["BoB"])) == {"Bob", "Böb", "Bøb"}
assert set(keyword.prepare_keywords(["bob"])) == {"Bob", "Böb", "Bøb"}
assert set(keyword.prepare_keywords(["balloon"])) == {
assert query.romanization() == {"n": ["ñ"], "o": ["ö", "ø"]}
assert set(query.prepare_keywords(["BOB"])) == {"Bob", "Böb", "Bøb"}
assert set(query.prepare_keywords(["BoB"])) == {"Bob", "Böb", "Bøb"}
assert set(query.prepare_keywords(["bob"])) == {"Bob", "Böb", "Bøb"}
assert set(query.prepare_keywords(["balloon"])) == {
"Balloon",
"Ballooñ",
"Balloön",
Expand Down

0 comments on commit 77eb9d0

Please sign in to comment.