-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
15 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
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 |
---|---|---|
|
@@ -51,6 +51,8 @@ | |
], | ||
# note this intentionally uses a tuple so that we can test immutable | ||
'email': ('django.forms.fields.EmailField',), | ||
'array': ['django.forms.fields.CharField', {'widget': 'django.forms.Textarea'}], | ||
'json': ['django.forms.fields.CharField', {'widget': 'django.forms.Textarea'}], | ||
} | ||
|
||
USE_TZ = True | ||
|
@@ -68,6 +70,19 @@ | |
'CHOICE_VALUE': ('yes', 'select yes or no', 'yes_no_null_select'), | ||
'LINEBREAK_VALUE': ('Spam spam', 'eggs\neggs'), | ||
'EMAIL_VALUE': ('[email protected]', 'An email', 'email'), | ||
'LIST_VALUE': ([1, '1', date(2019, 1, 1)], 'A list', 'array'), | ||
'JSON_VALUE': ( | ||
{ | ||
'key': 'value', | ||
'key2': 2, | ||
'key3': [1, 2, 3], | ||
'key4': {'key': 'value'}, | ||
'key5': date(2019, 1, 1), | ||
'key6': None, | ||
}, | ||
'A JSON object', | ||
'json', | ||
), | ||
} | ||
|
||
DEBUG = True | ||
|
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 |
---|---|---|
|
@@ -25,6 +25,18 @@ def test_store(self): | |
self.assertEqual(self.config.TIMEDELTA_VALUE, timedelta(days=1, hours=2, minutes=3)) | ||
self.assertEqual(self.config.CHOICE_VALUE, 'yes') | ||
self.assertEqual(self.config.EMAIL_VALUE, '[email protected]') | ||
self.assertEqual(self.config.LIST_VALUE, [1, '1', date(2019, 1, 1)]) | ||
self.assertEqual( | ||
self.config.JSON_VALUE, | ||
{ | ||
'key': 'value', | ||
'key2': 2, | ||
'key3': [1, 2, 3], | ||
'key4': {'key': 'value'}, | ||
'key5': date(2019, 1, 1), | ||
'key6': None, | ||
}, | ||
) | ||
|
||
# set values | ||
self.config.INT_VALUE = 100 | ||
|
@@ -38,6 +50,8 @@ def test_store(self): | |
self.config.TIMEDELTA_VALUE = timedelta(days=2, hours=3, minutes=4) | ||
self.config.CHOICE_VALUE = 'no' | ||
self.config.EMAIL_VALUE = '[email protected]' | ||
self.config.LIST_VALUE = [1, date(2020, 2, 2)] | ||
self.config.JSON_VALUE = {'key': 'OK'} | ||
|
||
# read again | ||
self.assertEqual(self.config.INT_VALUE, 100) | ||
|
@@ -51,6 +65,8 @@ def test_store(self): | |
self.assertEqual(self.config.TIMEDELTA_VALUE, timedelta(days=2, hours=3, minutes=4)) | ||
self.assertEqual(self.config.CHOICE_VALUE, 'no') | ||
self.assertEqual(self.config.EMAIL_VALUE, '[email protected]') | ||
self.assertEqual(self.config.LIST_VALUE, [1, date(2020, 2, 2)]) | ||
self.assertEqual(self.config.JSON_VALUE, {'key': 'OK'}) | ||
|
||
def test_nonexistent(self): | ||
self.assertRaises(AttributeError, getattr, self.config, 'NON_EXISTENT') | ||
|
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 |
---|---|---|
|
@@ -30,19 +30,21 @@ def test_list(self): | |
set( | ||
dedent( | ||
smart_str( | ||
""" BOOL_VALUE True | ||
EMAIL_VALUE [email protected] | ||
INT_VALUE 1 | ||
LINEBREAK_VALUE Spam spam | ||
DATE_VALUE 2010-12-24 | ||
TIME_VALUE 23:59:59 | ||
TIMEDELTA_VALUE 1 day, 2:03:00 | ||
STRING_VALUE Hello world | ||
CHOICE_VALUE yes | ||
DECIMAL_VALUE 0.1 | ||
DATETIME_VALUE 2010-08-23 11:29:24 | ||
FLOAT_VALUE 3.1415926536 | ||
""" | ||
""" BOOL_VALUE\tTrue | ||
EMAIL_VALUE\t[email protected] | ||
INT_VALUE\t1 | ||
LINEBREAK_VALUE\tSpam spam | ||
DATE_VALUE\t2010-12-24 | ||
TIME_VALUE\t23:59:59 | ||
TIMEDELTA_VALUE\t1 day, 2:03:00 | ||
STRING_VALUE\tHello world | ||
CHOICE_VALUE\tyes | ||
DECIMAL_VALUE\t0.1 | ||
DATETIME_VALUE\t2010-08-23 11:29:24 | ||
FLOAT_VALUE\t3.1415926536 | ||
JSON_VALUE\t{'key': 'value', 'key2': 2, 'key3': [1, 2, 3], 'key4': {'key': 'value'}, 'key5': datetime.date(2019, 1, 1), 'key6': None} | ||
LIST_VALUE\t[1, '1', datetime.date(2019, 1, 1)] | ||
""" # noqa: E501 | ||
) | ||
).splitlines() | ||
), | ||
|
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
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