コード例 #1
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_tags_with_double_quotes_can_contain_commas(self):
     """
     Double quotes can contain commas
     """
     self.assertEqual(parse_tags('a-one "a-two, and a-three"'),
                      [u'a-one', u'a-two, and a-three'])
     self.assertEqual(parse_tags('"two", one, one, two, "one"'),
                      [u'one', u'two'])
コード例 #2
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_tags_with_double_quotes_can_contain_commas(self):
     """
     Double quotes can contain commas
     """
     self.assertEqual(parse_tags('a-one "a-two, and a-three"'),
                      [u'a-one', u'a-two, and a-three'])
     self.assertEqual(parse_tags('"two", one, one, two, "one"'),
                      [u'one', u'two'])
コード例 #3
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_simple_space_delimited_tags(self):
     """
     Test with simple space-delimited tags.
     """
     self.assertEqual(parse_tags('one'), [u'one'])
     self.assertEqual(parse_tags('one two'), [u'one', u'two'])
     self.assertEqual(parse_tags('one two three'),
                      [u'one', u'three', u'two'])
     self.assertEqual(parse_tags('one one two two'), [u'one', u'two'])
コード例 #4
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_simple_space_delimited_tags(self):
     """
     Test with simple space-delimited tags.
     """
     self.assertEqual(parse_tags('one'), [u'one'])
     self.assertEqual(parse_tags('one two'), [u'one', u'two'])
     self.assertEqual(
         parse_tags('one two three'), [u'one', u'three', u'two'])
     self.assertEqual(parse_tags('one one two two'), [u'one', u'two'])
コード例 #5
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_comma_delimited_multiple_words(self):
     """
     Test with comma-delimited multiple words.
     An unquoted comma in the input will trigger this.
     """
     self.assertEqual(parse_tags(',one'), [u'one'])
     self.assertEqual(parse_tags(',one two'), [u'one two'])
     self.assertEqual(parse_tags(',one two three'), [u'one two three'])
     self.assertEqual(parse_tags('a-one, a-two and a-three'),
                      [u'a-one', u'a-two and a-three'])
コード例 #6
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_comma_delimited_multiple_words(self):
     """
     Test with comma-delimited multiple words.
     An unquoted comma in the input will trigger this.
     """
     self.assertEqual(parse_tags(',one'), [u'one'])
     self.assertEqual(parse_tags(',one two'), [u'one two'])
     self.assertEqual(parse_tags(',one two three'), [u'one two three'])
     self.assertEqual(parse_tags('a-one, a-two and a-three'),
                      [u'a-one', u'a-two and a-three'])
コード例 #7
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_double_quoted_multiple_words(self):
     """
     Test with double-quoted multiple words.
     A completed quote will trigger this.  Unclosed quotes are ignored.
     """
     self.assertEqual(parse_tags('"one'), [u'one'])
     self.assertEqual(parse_tags('"one two'), [u'one', u'two'])
     self.assertEqual(parse_tags('"one two three'),
                      [u'one', u'three', u'two'])
     self.assertEqual(parse_tags('"one two"'), [u'one two'])
     self.assertEqual(parse_tags('a-one "a-two and a-three"'),
                      [u'a-one', u'a-two and a-three'])
コード例 #8
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_double_quoted_multiple_words(self):
     """
     Test with double-quoted multiple words.
     A completed quote will trigger this.  Unclosed quotes are ignored.
     """
     self.assertEqual(parse_tags('"one'), [u'one'])
     self.assertEqual(parse_tags('"one two'), [u'one', u'two'])
     self.assertEqual(
         parse_tags('"one two three'), [u'one', u'three', u'two'])
     self.assertEqual(parse_tags('"one two"'), [u'one two'])
     self.assertEqual(parse_tags('a-one "a-two and a-three"'),
                      [u'a-one', u'a-two and a-three'])
コード例 #9
0
ファイル: forms.py プロジェクト: Gointer/collab
 def clean(self, value):
     value = super(TagField, self).clean(value)
     try:
         return parse_tags(value)
     except ValueError:
         raise forms.ValidationError(
             _("Please provide a comma-separated list of tags."))
コード例 #10
0
ファイル: forms.py プロジェクト: raviteja23/collab
 def clean(self, value):
     value = super(TagField, self).clean(value)
     try:
         return parse_tags(value)
     except ValueError:
         raise forms.ValidationError(
             _("Please provide a comma-separated list of tags."))
コード例 #11
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_naughty_input(self):
     """
     Test with naughty input.
     """
     # Bad users! Naughty users!
     self.assertEqual(parse_tags(None), [])
     self.assertEqual(parse_tags(''), [])
     self.assertEqual(parse_tags('"'), [])
     self.assertEqual(parse_tags('""'), [])
     self.assertEqual(parse_tags('"' * 7), [])
     self.assertEqual(parse_tags(',,,,,,'), [])
     self.assertEqual(parse_tags('",",",",",",","'), [u','])
     self.assertEqual(parse_tags('a-one "a-two" and "a-three'),
                      [u'a-one', u'a-three', u'a-two', u'and'])
コード例 #12
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_naughty_input(self):
     """
     Test with naughty input.
     """
     # Bad users! Naughty users!
     self.assertEqual(parse_tags(None), [])
     self.assertEqual(parse_tags(''), [])
     self.assertEqual(parse_tags('"'), [])
     self.assertEqual(parse_tags('""'), [])
     self.assertEqual(parse_tags('"' * 7), [])
     self.assertEqual(parse_tags(',,,,,,'), [])
     self.assertEqual(parse_tags('",",",",",",","'), [u','])
     self.assertEqual(parse_tags('a-one "a-two" and "a-three'),
                      [u'a-one', u'a-three', u'a-two', u'and'])
コード例 #13
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_loose_commas(self):
     """
     Loose commas - split on commas
     """
     self.assertEqual(parse_tags('"one", two three'),
                      [u'one', u'two three'])
コード例 #14
0
ファイル: tests.py プロジェクト: elucify/collab
 def test_with_no_loose_commas(self):
     """
     Test with no loose commas -- split on spaces.
     """
     self.assertEqual(parse_tags('one two "thr,ee"'),
                      [u'one', u'thr,ee', u'two'])
コード例 #15
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_loose_commas(self):
     """
     Loose commas - split on commas
     """
     self.assertEqual(
         parse_tags('"one", two three'), [u'one', u'two three'])
コード例 #16
0
ファイル: tests.py プロジェクト: Gointer/collab
 def test_with_no_loose_commas(self):
     """
     Test with no loose commas -- split on spaces.
     """
     self.assertEqual(
         parse_tags('one two "thr,ee"'), [u'one', u'thr,ee', u'two'])