-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce new widgets that pick up locale date formats
- Loading branch information
1 parent
a37c458
commit 25866bf
Showing
6 changed files
with
129 additions
and
18 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
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
|
||
from oscar.core.utils import slugify | ||
from oscar.core import utils | ||
|
||
|
||
class TestSlugify(TestCase): | ||
|
||
def test_uses_custom_mappings(self): | ||
mapping = {'c++': 'cpp'} | ||
with override_settings(OSCAR_SLUG_MAP=mapping): | ||
self.assertEqual('cpp', slugify('c++')) | ||
self.assertEqual('cpp', utils.slugify('c++')) | ||
|
||
def test_uses_blacklist(self): | ||
blacklist = ['the'] | ||
with override_settings(OSCAR_SLUG_BLACKLIST=blacklist): | ||
self.assertEqual('bible', slugify('The Bible')) | ||
self.assertEqual('bible', utils.slugify('The Bible')) | ||
|
||
|
Empty file.
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,32 @@ | ||
import nose | ||
|
||
from oscar.forms import widgets | ||
|
||
|
||
def test_datetime_to_date_format_conversion(): | ||
format_testcases = ( | ||
('%Y-%m-%d', 'yy-mm-dd'), | ||
('%Y-%m-%d %H:%M', 'yy-mm-dd'), | ||
) | ||
|
||
def compare(format, expected): | ||
nose.tools.eq_( | ||
widgets.datetime_format_to_js_date_format(format), expected) | ||
|
||
for format, expected in format_testcases: | ||
yield compare, format, expected | ||
|
||
|
||
def test_datetime_to_time_format_conversion(): | ||
format_testcases = ( | ||
('%Y-%m-%d', ''), | ||
('%Y-%m-%d %H:%M', 'HH:mm'), | ||
('%d/%m/%Y', ''), | ||
) | ||
|
||
def compare(format, expected): | ||
nose.tools.eq_( | ||
widgets.datetime_format_to_js_time_format(format), expected) | ||
|
||
for format, expected in format_testcases: | ||
yield compare, format, expected |