From 7e49bd3039efd692e17db7d236dd1f7e73ad01c0 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 24 May 2014 13:38:08 +0200 Subject: [PATCH] add first tests, add .coveragerc, ignore coverage files --- .gitignore | 2 ++ gnuviechadmin/.coveragerc | 5 +++++ gnuviechadmin/gnuviechadmin/tests.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 gnuviechadmin/.coveragerc create mode 100644 gnuviechadmin/gnuviechadmin/tests.py diff --git a/.gitignore b/.gitignore index bd152a2..47e4c46 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,6 @@ tramp Thumbs.db Desktop.ini +.coverage .ropeproject/ +htmlcov/ diff --git a/gnuviechadmin/.coveragerc b/gnuviechadmin/.coveragerc new file mode 100644 index 0000000..5126e58 --- /dev/null +++ b/gnuviechadmin/.coveragerc @@ -0,0 +1,5 @@ +[run] +source = gnuviechadmin,managemails + +[report] +omit = */migrations/*,*/tests/*.py,*/tests.py,gnuviechadmin/settings/local.py,gnuviechadmin/settings/production.py diff --git a/gnuviechadmin/gnuviechadmin/tests.py b/gnuviechadmin/gnuviechadmin/tests.py new file mode 100644 index 0000000..9c35fda --- /dev/null +++ b/gnuviechadmin/gnuviechadmin/tests.py @@ -0,0 +1,28 @@ +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)