-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/client-testing: Added test file
- Loading branch information
1 parent
79e31a0
commit aba942a
Showing
1 changed file
with
45 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,45 @@ | ||
try: | ||
from importlib import reload | ||
except ImportError: | ||
pass | ||
|
||
from django.conf import settings | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.test import TestCase, override_settings | ||
|
||
import captcha | ||
|
||
|
||
class TestInit(TestCase): | ||
|
||
def test_setting_instance_check(self): | ||
with override_settings(RECAPTCHA_PROXY="not a dict"): | ||
with self.assertRaises(ImproperlyConfigured) as error: | ||
reload(captcha) | ||
self.assertEqual(error.exception.args, ( | ||
"Setting RECAPTCHA_PROXY is not of type", dict) | ||
) | ||
with override_settings(RECAPTCHA_VERIFY_REQUEST_TIMEOUT="not an int"): | ||
with self.assertRaises(ImproperlyConfigured) as error: | ||
reload(captcha) | ||
self.assertEqual(error.exception.args, ( | ||
"Setting RECAPTCHA_VERIFY_REQUEST_TIMEOUT is not of type", int) | ||
) | ||
with override_settings(RECAPTCHA_VERIFY_ENDPOINT=1): | ||
with self.assertRaises(ImproperlyConfigured) as error: | ||
reload(captcha) | ||
self.assertEqual(error.exception.args, ( | ||
"Setting RECAPTCHA_VERIFY_ENDPOINT is not of type", str) | ||
) | ||
with override_settings(RECAPTCHA_PUBLIC_KEY=1): | ||
with self.assertRaises(ImproperlyConfigured) as error: | ||
reload(captcha) | ||
self.assertEqual(error.exception.args, ( | ||
"Setting RECAPTCHA_PUBLIC_KEY is not of type", str) | ||
) | ||
with override_settings(RECAPTCHA_PRIVATE_KEY=1): | ||
with self.assertRaises(ImproperlyConfigured) as error: | ||
reload(captcha) | ||
self.assertEqual(error.exception.args, ( | ||
"Setting RECAPTCHA_PRIVATE_KEY is not of type", str) | ||
) |