-
Notifications
You must be signed in to change notification settings - Fork 23
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
3 changed files
with
88 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,35 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import warnings | ||
|
||
from django.conf import settings | ||
from django.core.management import execute_from_command_line | ||
|
||
if not settings.configured: | ||
settings.configure( | ||
DATABASES={ | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
} | ||
}, | ||
INSTALLED_APPS=[ | ||
'django.contrib.contenttypes', | ||
'taggit_selectize', | ||
'taggit', | ||
'tests', | ||
], | ||
MIDDLEWARE_CLASSES=[], | ||
) | ||
|
||
|
||
warnings.simplefilter('default', DeprecationWarning) | ||
warnings.simplefilter('default', PendingDeprecationWarning) | ||
|
||
|
||
def runtests(): | ||
argv = sys.argv[:1] + ['test'] + sys.argv[1:] | ||
execute_from_command_line(argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
runtests() |
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,53 @@ | ||
from django.test import TestCase | ||
|
||
from taggit_selectize.utils import parse_tags | ||
|
||
|
||
class TestUtils(TestCase): | ||
def test_tag_parser(self): | ||
self.assertListEqual(parse_tags('foo, bar, baz'), ['bar', 'baz', 'foo']) | ||
|
||
def test_tag_parser_not_space_delimited(self): | ||
self.assertListEqual(parse_tags('foo bar'), ['foo bar']) | ||
|
||
def test_tag_parser_quoted(self): | ||
self.assertListEqual(parse_tags('"foo bar"'), ['foo bar']) | ||
|
||
def test_tag_parser_multiple_quoted(self): | ||
self.assertListEqual(parse_tags('"foo bar", "baz bongo"'), ['baz bongo', 'foo bar']) | ||
|
||
def test_tag_parser_dangling_quote(self): | ||
self.assertListEqual(parse_tags('"foo bar'), ['foo bar']) | ||
|
||
def test_tag_parser_quotes_take_precedence_over_commas(self): | ||
self.assertListEqual(parse_tags('"foo, bar"'), ['foo, bar']) | ||
|
||
def test_tag_parser_dangling_quote_with_comma(self): | ||
self.assertListEqual(parse_tags('"foo, bar'), ['bar', 'foo']) | ||
|
||
def test_tag_parser_dangling_quote_at_end(self): | ||
self.assertListEqual(parse_tags('foo bar"'), ['foo bar']) | ||
|
||
def test_tag_parser_empty_string(self): | ||
self.assertListEqual(parse_tags(''), []) | ||
|
||
def test_tag_parser_single_comma(self): | ||
self.assertListEqual(parse_tags(','), []) | ||
|
||
def test_tag_parser_multiple_commas(self): | ||
self.assertListEqual(parse_tags(',,,,'), []) | ||
|
||
def test_tag_parser_extra_comma(self): | ||
self.assertListEqual(parse_tags('foo,,bar'), ['bar', 'foo']) | ||
|
||
def test_tag_parser_extra_opening_quote(self): | ||
self.assertListEqual(parse_tags('""foo bar"'), ['foo bar']) | ||
|
||
def test_tag_parser_extra_closing_quote(self): | ||
self.assertListEqual(parse_tags('"foo bar""'), ['foo bar']) | ||
|
||
def test_tag_parser_extra_quotes_and_commas(self): | ||
self.assertListEqual(parse_tags('""foo,",bar",,baz"""'), [',bar', 'baz', 'foo']) | ||
|
||
|
||
|