Ejemplo n.º 1
0
 def __get__(self, instance, cls):
     if not cls.model or isinstance(cls.model, str):
         return None
     return slugify(cls.model.__plural_label__)
Ejemplo n.º 2
0
def test_slugify():
    assert slugify('aCamelCasedString') == 'a-camel-cased-string'
    assert slugify('A_snake_cased_string') == 'a-snake-cased-string'
    assert slugify('A-kebab-cased-string') == 'a-kebab-cased-string'
    assert slugify('A normal sentence') == 'a-normal-sentence'
    assert slugify('multiple   spaces') == 'multiple-spaces'
    assert slugify('multiple---dashes') == 'multiple-dashes'
    assert slugify('Héllö Wørld') == 'hello-wrld'  # unicode-to-ascii is so-so
    assert slugify('_an underscore-prefix') == 'an-underscore-prefix'
    assert slugify('FoobarAPIController') == 'foobar-api-controller'
    assert slugify('') == ''
    assert slugify(None) is None