Skip to content

Commit

Permalink
Adding a String type token
Browse files Browse the repository at this point in the history
  • Loading branch information
zpetrace committed Sep 3, 2024
1 parent a0cddbe commit b000b94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion testimony/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Automated
...
Currently only supported type is 'choice', but in the future more can be added.
Currently only supported types are 'choice' and 'string', but in the future more can be added.
"""

import yaml
Expand Down Expand Up @@ -79,6 +79,9 @@ def __init__(self, name, config):
self.choices = [i if self.casesensitive else i.lower()
for i in config['choices']]

elif self.token_type == 'string':
pass

def update(self, new_values):
"""Update token configuration with dictionary of new values."""
for key, value in new_values.items():
Expand All @@ -90,4 +93,6 @@ def validate(self, what):
if not self.casesensitive:
what = what.lower()
return what in self.choices
elif self.token_type == 'string':
return isinstance(what, str) # validate that it's a string
return True # assume valid for unknown types
1 change: 1 addition & 0 deletions testimony/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

TOKEN_TYPES = [
'choice',
'string'
]

DEFAULT_TOKENS = (
Expand Down

0 comments on commit b000b94

Please sign in to comment.