combo/tests/test_utils.py

17 lines
644 B
Python

from combo.utils import aes_hex_decrypt, aes_hex_encrypt, get_templated_url
from django.conf import settings
from django.test import override_settings
def test_crypto_url():
invoice_id = '12-1234'
key = settings.SECRET_KEY
assert aes_hex_decrypt(key, aes_hex_encrypt(key, invoice_id)) == invoice_id
def test_templated_url():
assert get_templated_url('[test_url]') == '[test_url]'
with override_settings(TEMPLATE_VARS={'test_url': 'http://www.example.net'}):
assert get_templated_url('[test_url]') == 'http://www.example.net'
assert get_templated_url('[test_url]/hello') == 'http://www.example.net/hello'