chore(keyringctl): add test for simplify_ascii

This commit is contained in:
Levente Polyak 2021-11-09 20:04:22 +01:00
parent 83a345a1b8
commit e8fb9d17b3
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
2 changed files with 15 additions and 2 deletions

View File

@ -292,8 +292,6 @@ ascii_mapping: Dict[str, str] = {
ascii_mapping_lookup: Dict[str, str] = {} ascii_mapping_lookup: Dict[str, str] = {}
for key, value in ascii_mapping.items(): for key, value in ascii_mapping.items():
for c in key: for c in key:
if c in ascii_mapping_lookup:
raise Exception(f"duplicate ascii mapping: {c}")
ascii_mapping_lookup[c] = value ascii_mapping_lookup[c] = value
ascii_mapping_lookup[c.upper()] = value.upper() ascii_mapping_lookup[c.upper()] = value.upper()

View File

@ -181,3 +181,18 @@ def test_filter_fingerprints_by_trust(
trusts: Dict[Fingerprint, Trust], trust: Trust, result: List[Fingerprint] trusts: Dict[Fingerprint, Trust], trust: Trust, result: List[Fingerprint]
) -> None: ) -> None:
assert util.filter_fingerprints_by_trust(trusts=trusts, trust=trust) == result assert util.filter_fingerprints_by_trust(trusts=trusts, trust=trust) == result
@mark.parametrize(
"_str, result",
[
("foobar", "foobar"),
("", ""),
("bbàáâãğț aa", "bbaaaagt_aa"),
("<>", ""),
("!#$%^&*()_☃", "___________"),
("_-.+@", "_-.+@"),
],
)
def test_simplify_ascii(_str: str, result: str) -> None:
assert util.simplify_ascii(_str=_str) == result