Jan Dittberner
4b060c51f4
This commit adds test coverage for gvaldap and ldapentities and starts to provide coverage for ldaptasks using mockldap.
28 lines
808 B
Python
28 lines
808 B
Python
"""
|
|
This module implements tests for :py:mod:`gvaldap.settings`.
|
|
|
|
"""
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
from unittest import TestCase
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
from gvaldap.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')
|