Skip to content

Commit

Permalink
Merge pull request #156 from zpetrace/zpetrace/string_token
Browse files Browse the repository at this point in the history
Adding a String type token
  • Loading branch information
JacobCallahan authored Sep 3, 2024
2 parents a0cddbe + 71afc9e commit 6622ba0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testimony/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
- 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 +80,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 +94,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 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 6622ba0

Please sign in to comment.