gva/gnuviechadmin/gnuviechadmin/tests.py

28 lines
856 B
Python

import os
from unittest import TestCase
from django.core.exceptions import ImproperlyConfigured
from gnuviechadmin.settings.base import get_env_variable
class GetEnvVariableTest(TestCase):
def test_get_existing_env_variable(self):
os.environ['testvariable'] = 'myvalue'
self.assertEqual(get_env_variable('testvariable'), 'myvalue')
def test_get_missing_env_variable(self):
if 'missingvariable' in os.environ:
del os.environ['missingvariable']
with self.assertRaises(ImproperlyConfigured) as e:
get_env_variable('missingvariable')
self.assertEqual(
str(e.exception), 'Set the missingvariable environment variable')
class WSGITest(TestCase):
def test_wsgi_application(self):
from gnuviechadmin import wsgi
self.assertIsNotNone(wsgi.application)