Jan Dittberner
7bcb0d3100
This commit adds new tests for the gnuviechadmin.context_processors module. The module gnuviechadmin.tests has been moved into a separate directory for a more clear structure.
24 lines
745 B
Python
24 lines
745 B
Python
# -*- python -*-
|
|
# -*- coding: utf-8 -*-
|
|
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')
|