Skip to content

Commit

Permalink
add pypy, PY3.4, Django 1.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
un33k committed Oct 17, 2014
1 parent a3ad87f commit 06c853b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 14 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- pypy

env:
- DJANGO=1.5.5
- DJANGO=1.6.2
- DJANGO=1.7
- DJANGO=1.6.7
- DJANGO=1.4.15

install:
- pip install -q Django==$DJANGO
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.0.3

Enhancement:

- Support pypy
- Support Django 1.7
- More test cases
- Update slugify

## 1.0.2

Enhancement:
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Unicode Test
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")

txt = '影師嗎'
r = slugify(txt)
self.assertEqual(r, "ying-shi-ma")

txt = 'C\'est déjà l\'été.'
r = slugify(txt)
self.assertEqual(r, "cest-deja-lete")
Expand Down Expand Up @@ -89,6 +93,15 @@ Unicode Test
r = slugify(txt, max_length=20, word_boundary=True, separator="ZZZZZZ")
self.assertEqual(r, "jajaZZZZZZlolZZZZZZmememeooZZZZZZa")

txt = "___This is a test ---"
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")

txt = "___This is a test___"
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")


Uniqueness Test

Override your object's save method with something like this (models.py)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-slugify>=0.0.4
python-slugify>=0.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
author = 'Val Neekman'
author_email = 'info@neekware.com'
license = 'BSD'
install_requires = ['python-slugify>=0.0.7']
install_requires = ['python-slugify>=0.1.0']
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
Expand Down
4 changes: 3 additions & 1 deletion uuslug/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-

__version__ = '1.0.2'
__version__ = '1.0.3'

default_app_config = 'uuslug.apps.AppConfig'

from django.utils import six

Expand Down
11 changes: 11 additions & 0 deletions uuslug/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.apps import apps
from django.apps import AppConfig as DjangoAppConfig
from django.utils.translation import ugettext_lazy as _


class AppConfig(DjangoAppConfig):
"""
Configuration entry point for the uuslug app
"""
label = name = 'uuslug'
verbose_name = _("uuslug app")
30 changes: 21 additions & 9 deletions uuslug/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.test import TestCase

# http://pypi.python.org/pypi/django-tools/
#from django_tools.unittest_utils.print_sql import PrintQueries
# from django_tools.unittest_utils.print_sql import PrintQueries

from uuslug import slugify
from uuslug.models import (CoolSlug, AnotherSlug, TruncatedSlug,
Expand All @@ -24,6 +24,10 @@ def test_manager(self):
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")

txt = '影師嗎'
r = slugify(txt)
self.assertEqual(r, "ying-shi-ma")

txt = 'C\'est déjà l\'été.'
r = slugify(txt)
self.assertEqual(r, "cest-deja-lete")
Expand Down Expand Up @@ -72,21 +76,29 @@ def test_manager(self):
r = slugify(txt, max_length=20, word_boundary=True, separator="ZZZZZZ")
self.assertEqual(r, "jajaZZZZZZlolZZZZZZmememeooZZZZZZa")

txt = "___This is a test ---"
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")

txt = "___This is a test___"
r = slugify(txt)
self.assertEqual(r, "this-is-a-test")


class SlugUniqueTestCase(TestCase):
"""Tests for Slug - Unique"""

def test_manager(self):
name = "john"

#with PrintQueries("create first john"): # display the SQL queries
# with PrintQueries("create first john"): # display the SQL queries
with self.assertNumQueries(2):
# 1. query: SELECT test, if slug 'john' exists
# 2. query: INSERT values
obj = CoolSlug.objects.create(name=name)
self.assertEqual(obj.slug, "john")

#with PrintQueries("create second john"): # display the SQL queries
# with PrintQueries("create second john"): # display the SQL queries
with self.assertNumQueries(3):
# 1. query: SELECT test, if slug 'john' exists
# 2. query: SELECT test, if slug 'john-1' exists
Expand All @@ -97,22 +109,22 @@ def test_manager(self):
def test_start_no(self):
name = 'Foo Bar'

#with PrintQueries("create first 'Foo Bar'"): # display the SQL queries
# with PrintQueries("create first 'Foo Bar'"): # display the SQL queries
with self.assertNumQueries(2):
# 1. query: SELECT test, if slug 'foo-bar' exists
# 2. query: INSERT values
obj = AnotherSlug.objects.create(name=name)
self.assertEqual(obj.slug, "foo-bar")

#with PrintQueries("create second 'Foo Bar'"): # display the SQL queries
# with PrintQueries("create second 'Foo Bar'"): # display the SQL queries
with self.assertNumQueries(3):
# 1. query: SELECT test, if slug 'foo-bar' exists
# 2. query: SELECT test, if slug 'foo-bar-2' exists
# 3. query: INSERT values
obj = AnotherSlug.objects.create(name=name)
self.assertEqual(obj.slug, "foo-bar-2")

#with PrintQueries("create third 'Foo Bar'"): # display the SQL queries
# with PrintQueries("create third 'Foo Bar'"): # display the SQL queries
with self.assertNumQueries(4):
# 1. query: SELECT test, if slug 'foo-bar' exists
# 2. query: SELECT test, if slug 'foo-bar-2' exists
Expand Down Expand Up @@ -152,22 +164,22 @@ class SlugUniqueDifferentSeparatorTestCase(TestCase):
def test_manager(self):
name = "john"

#with PrintQueries("create first john"): # display the SQL queries
# with PrintQueries("create first john"): # display the SQL queries
with self.assertNumQueries(2):
# 1. query: SELECT test, if slug 'john' exists
# 2. query: INSERT values
obj = CoolSlugDifferentSeparator.objects.create(name=name)
self.assertEqual(obj.slug, "john")

#with PrintQueries("create second john"): # display the SQL queries
# with PrintQueries("create second john"): # display the SQL queries
with self.assertNumQueries(3):
# 1. query: SELECT test, if slug 'john' exists
# 2. query: SELECT test, if slug 'john-1' exists
# 3. query: INSERT values
obj = CoolSlugDifferentSeparator.objects.create(name=name)
self.assertEqual(obj.slug, "john_1")

#with PrintQueries("create third john"): # display the SQL queries
# with PrintQueries("create third john"): # display the SQL queries
with self.assertNumQueries(4):
# 1. query: SELECT test, if slug 'john' exists
# 2. query: SELECT test, if slug 'john-1' exists
Expand Down
1 change: 1 addition & 0 deletions uuslug/testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
}
SECRET_KEY = "un33k"
INSTALLED_APPS = ['uuslug']
MIDDLEWARE_CLASSES = []

0 comments on commit 06c853b

Please sign in to comment.