Exemplo n.º 1
0
def parse_comment_currency(comment_text, fallback_currency=FALLBACK_CURRENCY):
    """Get the first token defined in comment_text."""
    CURRENCIES = set(map(lambda currency: currency['name'], get_tokens()))
    or_currencies = '|'.join(CURRENCIES)
    re_currencies = fr'({or_currencies})'
    result = re.findall(re_currencies, comment_text)
    return result[0] if result else fallback_currency
Exemplo n.º 2
0
 def test_tokens(self):
     """Test the dashboard tokens variable to ensure it can be read properly."""
     tokens = get_tokens()
     assert isinstance(tokens, list)
     assert isinstance(tokens[0], dict)
     assert len(tokens[0]) == 5