Skip to content

Commit

Permalink
feature/client-testing: Added test file
Browse files Browse the repository at this point in the history
  • Loading branch information
AltusBarry committed Jan 14, 2019
1 parent 79e31a0 commit aba942a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions captcha/tests/tests.py
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)
)

0 comments on commit aba942a

Please sign in to comment.