mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
fix(tokens-repo): fix is_name_exists() being fallible
This commit is contained in:
parent
2a239e35ad
commit
22a309466e
|
@ -70,10 +70,7 @@ class AbstractTokensRepository(ABC):
|
|||
|
||||
def is_token_name_exists(self, token_name: str) -> bool:
|
||||
"""Check if the token name exists"""
|
||||
token = self.get_token_by_name(token_name)
|
||||
if token is None:
|
||||
return False
|
||||
return True
|
||||
return token_name in [token.device_name for token in self.get_tokens()]
|
||||
|
||||
def is_token_name_pair_valid(self, token_name: str, token_string: str) -> bool:
|
||||
"""Check if the token name and token are valid"""
|
||||
|
|
|
@ -215,6 +215,13 @@ def test_is_token_name_pair_valid(some_tokens_repo):
|
|||
assert not repo.is_token_name_pair_valid("gibberish", token.token)
|
||||
|
||||
|
||||
def test_is_token_name_exists(some_tokens_repo):
|
||||
repo = some_tokens_repo
|
||||
token = repo.get_tokens()[0]
|
||||
assert repo.is_token_name_exists(token.device_name)
|
||||
assert not repo.is_token_name_exists("gibberish")
|
||||
|
||||
|
||||
def test_get_tokens(some_tokens_repo):
|
||||
repo = some_tokens_repo
|
||||
tokenstrings = []
|
||||
|
|
Loading…
Reference in a new issue