Skip to content

Commit

Permalink
Merge pull request #17 from johngian/test-utils
Browse files Browse the repository at this point in the history
Add test coverage for utils.
  • Loading branch information
johngian committed Oct 26, 2016
2 parents 77b3445 + c222aa0 commit 482f52b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings

from mozilla_django_oidc.utils import import_from_settings


class SettingImportTestCase(TestCase):

@override_settings(EXAMPLE_VARIABLE='example_value')
def test_attr_existing_no_default_value(self):
s = import_from_settings('EXAMPLE_VARIABLE')
self.assertEqual(s, 'example_value')

def test_attr_nonexisting_no_default_value(self):
with self.assertRaises(ImproperlyConfigured):
import_from_settings('EXAMPLE_VARIABLE')

def test_attr_nonexisting_default_value(self):
s = import_from_settings('EXAMPLE_VARIABLE', 'example_default')
self.assertEqual(s, 'example_default')

0 comments on commit 482f52b

Please sign in to comment.