Make tests neutral to settings

This commit is contained in:
Quantum 2022-01-24 20:51:14 -05:00
parent e43c5792c7
commit ff74e1c502
2 changed files with 11 additions and 7 deletions

View file

@ -1,12 +1,16 @@
from django.contrib.auth.models import User
from django.core import mail
from django.test import TestCase
from django.test import TestCase, override_settings
from django.utils import timezone
from qlinks.email import send_broken_email
from qlinks.models import Link
@override_settings(
QLINKS_CANONICAL='https://short.example/',
QLINKS_BROKEN_EMAIL=True,
)
class EmailTest(TestCase):
def create_link(self, user) -> Link:
return Link.objects.create(

View file

@ -1,9 +1,10 @@
from django.test import TestCase
from django.test import TestCase, override_settings
from django.utils import timezone
from qlinks.models import Link
@override_settings(QLINKS_CANONICAL='https://short.example/')
class LinkTestCase(TestCase):
def setUp(self) -> None:
Link.objects.create(
@ -14,7 +15,6 @@ class LinkTestCase(TestCase):
)
def test_short_url(self):
with self.settings(QLINKS_CANONICAL='https://short.example/'):
self.assertEqual(
Link.objects.get(short='short').short_url,
'https://short.example/short'