ADD: dav_base: some simple test cases.
This commit is contained in:
0
dav_base/tests/__init__.py
Normal file
0
dav_base/tests/__init__.py
Normal file
16
dav_base/tests/test_apps.py
Normal file
16
dav_base/tests/test_apps.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from django.apps import apps
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
|
||||||
|
class AppsTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
app_config = apps.get_containing_app_config(__package__)
|
||||||
|
self.settings = app_config.settings
|
||||||
|
|
||||||
|
def test_settings(self):
|
||||||
|
setting_names = ('email_sender',
|
||||||
|
'email_base_url',
|
||||||
|
'email_subject_prefix')
|
||||||
|
|
||||||
|
for s in setting_names:
|
||||||
|
self.assertTrue(hasattr(self.settings, s), 'Settings do not contain {}'.format(s))
|
||||||
20
dav_base/tests/test_emails.py
Normal file
20
dav_base/tests/test_emails.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from ..emails import AbstractMail
|
||||||
|
|
||||||
|
|
||||||
|
class EmailsTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.email = AbstractMail()
|
||||||
|
|
||||||
|
def test_send(self):
|
||||||
|
try:
|
||||||
|
self.email.send()
|
||||||
|
self.assertTrue(False, 'AbstractEmail.send() does not raise an Exception')
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
|
except ImproperlyConfigured:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
self.assertTrue(False, 'AbstractEmail.send() raised unexpected Exception')
|
||||||
33
dav_base/tests/test_urls.py
Normal file
33
dav_base/tests/test_urls.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from django.test import TestCase, Client
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from ..views import RootView
|
||||||
|
|
||||||
|
|
||||||
|
class UrlsTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
|
|
||||||
|
def test_root(self):
|
||||||
|
url = '/'
|
||||||
|
response = self.client.get(url, follow=False)
|
||||||
|
self.assertEqual(response.status_code, 200,
|
||||||
|
'Getting {} is not OK'.format(url))
|
||||||
|
self.assertEqual(response.resolver_match.func.__name__,
|
||||||
|
RootView.as_view().__name__,
|
||||||
|
'Getting {} resolve to wrong view'.format(url))
|
||||||
|
|
||||||
|
def test_root_by_name(self):
|
||||||
|
name = 'root'
|
||||||
|
response = self.client.get(reverse(name), follow=False)
|
||||||
|
self.assertEqual(response.status_code, 200,
|
||||||
|
'Getting url named \'{}\' is not OK'.format(name))
|
||||||
|
self.assertEqual(response.resolver_match.func.__name__,
|
||||||
|
RootView.as_view().__name__,
|
||||||
|
'Getting url named \'{}\' resolve to wrong view'.format(name))
|
||||||
|
|
||||||
|
def test_djangoadmin(self):
|
||||||
|
url = '/djangoadmin'
|
||||||
|
response = self.client.get(url, follow=True)
|
||||||
|
self.assertEqual(response.status_code, 200,
|
||||||
|
'Getting {} is not OK'.format(url))
|
||||||
10
dav_base/tests/test_views.py
Normal file
10
dav_base/tests/test_views.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.test import TestCase, Client
|
||||||
|
|
||||||
|
|
||||||
|
class ViewsTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
|
|
||||||
|
def test_root(self):
|
||||||
|
response = self.client.get('/', follow=False)
|
||||||
|
self.assertIn('root_urls', response.context, '\'root_urls\' not in context of root view')
|
||||||
Reference in New Issue
Block a user