-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from johngian/test-utils
Add test coverage for utils.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |