2022-01-24 20:51:14 -05:00
|
|
|
from django.test import TestCase, override_settings
|
2022-01-24 18:42:36 -05:00
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
from qlinks.models import Link
|
|
|
|
|
|
|
|
|
2022-01-24 20:51:14 -05:00
|
|
|
@override_settings(QLINKS_CANONICAL='https://short.example/')
|
2022-01-24 18:42:36 -05:00
|
|
|
class LinkTestCase(TestCase):
|
|
|
|
def setUp(self) -> None:
|
|
|
|
Link.objects.create(
|
|
|
|
short='short',
|
|
|
|
long='https://long.example.com',
|
|
|
|
is_working=True,
|
|
|
|
last_check=timezone.now(),
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_short_url(self):
|
2022-01-24 20:51:14 -05:00
|
|
|
self.assertEqual(
|
|
|
|
Link.objects.get(short='short').short_url,
|
|
|
|
'https://short.example/short'
|
|
|
|
)
|