@@ -43,30 +43,51 @@ def test_populate_auto(cls):
43
43
cls ._test_populate (cls .AutoSlugModel )
44
44
45
45
@classmethod
46
- def test_populate_magic (cls ):
46
+ def test_populate_unique (cls ):
47
47
cls ._test_populate (cls .MagicSlugModel )
48
48
49
49
@classmethod
50
50
def test_populate_multiple_languages_auto (cls ):
51
51
cls ._test_populate_multiple_languages (cls .AutoSlugModel )
52
52
53
53
@classmethod
54
- def test_populate_multiple_languages_magic (cls ):
54
+ def test_populate_multiple_languages_unique (cls ):
55
55
cls ._test_populate_multiple_languages (cls .MagicSlugModel )
56
56
57
57
@classmethod
58
58
def test_unique_slug_auto (cls ):
59
59
cls ._test_unique_slug (cls .AutoSlugModel )
60
60
61
61
@classmethod
62
- def test_unique_slug_magic (cls ):
62
+ def test_unique_slug_unique (cls ):
63
63
cls ._test_unique_slug (cls .MagicSlugModel )
64
64
65
- def test_unique_slug_magic_max_retries (self ):
66
- """Tests whether the magic slug implementation doesn't
65
+ @staticmethod
66
+ def test_unique_slug_with_time ():
67
+ """Tests whether the primary key is included in
68
+ the slug when the 'use_pk' option is enabled."""
69
+
70
+ title = 'myuniquetitle'
71
+
72
+ PkModel = get_fake_model (
73
+ 'PkModel' ,
74
+ {
75
+ 'title' : LocalizedField (),
76
+ 'slug' : LocalizedUniqueSlugField (populate_from = 'title' , include_time = True )
77
+ }
78
+ )
79
+
80
+ obj = PkModel ()
81
+ obj .title .en = title
82
+ obj .save ()
83
+
84
+ assert obj .slug .en .startswith ('%s-' % title )
85
+
86
+ def test_unique_slug_unique_max_retries (self ):
87
+ """Tests whether the unique slug implementation doesn't
67
88
try to find a slug forever and gives up after a while."""
68
89
69
- title = 'mymagictitle '
90
+ title = 'myuniquetitle '
70
91
71
92
obj = self .MagicSlugModel ()
72
93
obj .title .en = title
@@ -83,23 +104,23 @@ def test_unique_slug_utf_auto(cls):
83
104
cls ._test_unique_slug_utf (cls .AutoSlugModel )
84
105
85
106
@classmethod
86
- def test_unique_slug_utf_magic (cls ):
107
+ def test_unique_slug_utf_unique (cls ):
87
108
cls ._test_unique_slug_utf (cls .MagicSlugModel )
88
109
89
110
@classmethod
90
111
def test_deconstruct_auto (cls ):
91
112
cls ._test_deconstruct (LocalizedAutoSlugField )
92
113
93
114
@classmethod
94
- def test_deconstruct_magic (cls ):
115
+ def test_deconstruct_unique (cls ):
95
116
cls ._test_deconstruct (LocalizedUniqueSlugField )
96
117
97
118
@classmethod
98
119
def test_formfield_auto (cls ):
99
120
cls ._test_formfield (LocalizedAutoSlugField )
100
121
101
122
@classmethod
102
- def test_formfield_magic (cls ):
123
+ def test_formfield_unique (cls ):
103
124
cls ._test_formfield (LocalizedUniqueSlugField )
104
125
105
126
@staticmethod
@@ -130,7 +151,7 @@ def _test_populate_multiple_languages(model):
130
151
def _test_unique_slug (model ):
131
152
"""Tests whether unique slugs are properly generated."""
132
153
133
- title = 'mymagictitle '
154
+ title = 'myuniquetitle '
134
155
135
156
obj = model ()
136
157
obj .title .en = title
0 commit comments