-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement wildcard-sensitive number search * add tests * refactoring * refactoring
- Loading branch information
1 parent
1844242
commit 27f2b86
Showing
4 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from ebl.transliteration.infrastructure.queries import build_query | ||
|
||
|
||
PATH_PREFIX = "someNumber" | ||
|
||
|
||
def create_dto(prefix, number, suffix) -> dict: | ||
dto = { | ||
"prefix": prefix, | ||
"number": number, | ||
"suffix": suffix, | ||
} | ||
return {key: value for key, value in dto.items() if value is not None} | ||
|
||
|
||
def add_path_prefix(dto: dict): | ||
return {f"{PATH_PREFIX}.{key}": value for key, value in dto.items()} | ||
|
||
|
||
PREFIXES = ["X", "", "*"] | ||
NUMBERS = ["123", "", "*"] | ||
SUFFIXES = ["a", "", "*"] | ||
WILDCARDS = [True, False] | ||
|
||
|
||
@pytest.mark.parametrize("prefix", PREFIXES) | ||
@pytest.mark.parametrize("number", NUMBERS) | ||
@pytest.mark.parametrize("suffix", SUFFIXES) | ||
@pytest.mark.parametrize("wildcard", WILDCARDS) | ||
def test_build_query(prefix, number, suffix, wildcard): | ||
suffix = "*" if wildcard and number == "*" and not suffix else suffix | ||
data = (prefix, number, suffix) | ||
dto = create_dto(*data) | ||
expected = add_path_prefix( | ||
create_dto(*(None if wildcard and value == "*" else value for value in data)) | ||
) | ||
assert build_query(PATH_PREFIX, dto, wildcard) == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters