Exemplo n.º 1
0
 def test_slugify(self):
     self.assertSetEqual(clean_tags(self.request, 'green eggs and ham'),
                         ['green eggs and ham'])
     self.assertSetEqual(clean_tags(self.request, 'ONE fish, TWO fish'),
                         ['one fish', 'two fish'])
     self.assertSetEqual(clean_tags(self.request, 'ONE fish, TWO fish, ,,'),
                         ['one fish', 'two fish'])
Exemplo n.º 2
0
 def test_max_length(self):
     # The max length is defined on the Tag model at 128 characters.
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'x' * 129)
     eq_(
         e.exception.message, 'All tags must be 128 characters or less '
         'after invalid characters are removed.')
Exemplo n.º 3
0
 def test_slugify(self):
     self.assertSetEqual(clean_tags(self.request, 'green eggs and ham'),
                         ['green eggs and ham'])
     self.assertSetEqual(clean_tags(self.request, 'ONE fish, TWO fish'),
                         ['one fish', 'two fish'])
     self.assertSetEqual(clean_tags(self.request, 'ONE fish, TWO fish, ,,'),
                         ['one fish', 'two fish'])
Exemplo n.º 4
0
 def test_restricted_max_tags(self):
     """Test restricted tags don't count towards the max total."""
     mkt.MAX_TAGS = 3
     self.request.groups = [self.grant_permission(self.user, 'Apps:Edit')]
     Tag.objects.create(tag_text='lorax', restricted=True)
     self.assertSetEqual(clean_tags(self.request, 'one, two, three, lorax'),
                         ['one', 'two', 'three', 'lorax'])
Exemplo n.º 5
0
 def clean_keywords(self):
     # We set a high `max_tags` here b/c the keywords data is coming from
     # the website meta data which can contain a higher number of tags than
     # apps.
     return clean_tags(self.request,
                       self.cleaned_data['keywords'],
                       max_tags=100)
Exemplo n.º 6
0
 def test_restricted_max_tags(self):
     """Test restricted tags don't count towards the max total."""
     mkt.MAX_TAGS = 3
     self.request.groups = [self.grant_permission(self.user, 'Apps:Edit')]
     Tag.objects.create(tag_text='lorax', restricted=True)
     self.assertSetEqual(
         clean_tags(self.request, 'one, two, three, lorax'),
         ['one', 'two', 'three', 'lorax'])
Exemplo n.º 7
0
 def test_blocked(self):
     Tag.objects.create(tag_text='grinch', blocked=True)
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'grinch, lorax')
     eq_(e.exception.message, 'Invalid tag: grinch')
Exemplo n.º 8
0
 def test_restricted_tag_with_privileges(self):
     self.request.groups = [self.grant_permission(self.user, 'Apps:Edit')]
     Tag.objects.create(tag_text='thing one', restricted=True)
     self.assertSetEqual(clean_tags(self.request, 'thing one, thing two'),
                         ['thing one', 'thing two'])
Exemplo n.º 9
0
 def test_restricted_tag(self):
     Tag.objects.create(tag_text='thing one', restricted=True)
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'thing one, thing two')
     eq_(e.exception.message,
         '"thing one" is a reserved tag and cannot be used.')
Exemplo n.º 10
0
 def test_max_tags(self):
     mkt.MAX_TAGS = 3
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'one fish, two fish, red fish, blue fish')
     eq_(e.exception.message, 'You have 1 too many tags.')
Exemplo n.º 11
0
 def test_slugify_unicode(self):
     self.assertSetEqual(clean_tags(self.request, u'Dr. Seüss'),
                         [u'dr seüss'])
Exemplo n.º 12
0
 def test_min_length(self):
     mkt.MIN_TAG_LENGTH = 2
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'a, b, c')
     eq_(e.exception.message, 'All tags must be at least 2 characters.')
Exemplo n.º 13
0
 def clean_tags(self):
     return clean_tags(self.request, self.cleaned_data['tags'])
Exemplo n.º 14
0
 def test_blocked(self):
     Tag.objects.create(tag_text='grinch', blocked=True)
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'grinch, lorax')
     eq_(e.exception.message, 'Invalid tag: grinch')
Exemplo n.º 15
0
 def test_restricted_tag_with_privileges(self):
     self.request.groups = [self.grant_permission(self.user, 'Apps:Edit')]
     Tag.objects.create(tag_text='thing one', restricted=True)
     self.assertSetEqual(clean_tags(self.request, 'thing one, thing two'),
                         ['thing one', 'thing two'])
Exemplo n.º 16
0
 def test_restricted_tag(self):
     Tag.objects.create(tag_text='thing one', restricted=True)
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'thing one, thing two')
     eq_(e.exception.message,
         '"thing one" is a reserved tag and cannot be used.')
Exemplo n.º 17
0
 def test_max_tags(self):
     mkt.MAX_TAGS = 3
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'one fish, two fish, red fish, blue fish')
     eq_(e.exception.message, 'You have 1 too many tags.')
Exemplo n.º 18
0
 def test_max_length(self):
     # The max length is defined on the Tag model at 128 characters.
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'x' * 129)
     eq_(e.exception.message, 'All tags must be 128 characters or less '
                              'after invalid characters are removed.')
Exemplo n.º 19
0
 def clean_tags(self):
     return clean_tags(self.request, self.cleaned_data["tags"])
Exemplo n.º 20
0
 def test_slugify_unicode(self):
     self.assertSetEqual(clean_tags(self.request, u'Dr. Seüss'),
                         [u'dr seüss'])
Exemplo n.º 21
0
 def clean_keywords(self):
     # We set a high `max_tags` here b/c the keywords data is coming from
     # the website meta data which can contain a higher number of tags than
     # apps.
     return clean_tags(self.request, self.cleaned_data['keywords'],
                       max_tags=100)
Exemplo n.º 22
0
 def test_min_length(self):
     mkt.MIN_TAG_LENGTH = 2
     with self.assertRaises(forms.ValidationError) as e:
         clean_tags(self.request, 'a, b, c')
     eq_(e.exception.message, 'All tags must be at least 2 characters.')
Exemplo n.º 23
0
 def clean_tags(self):
     return clean_tags(self.request, self.cleaned_data['tags'])
Exemplo n.º 24
0
 def clean_keywords(self):
     return clean_tags(self.request, self.cleaned_data['keywords'])