|
|
@@ -4,21 +4,24 @@ from django.core.exceptions import ValidationError
|
|
4
|
4
|
from django.core.urlresolvers import reverse
|
|
5
|
5
|
|
|
6
|
6
|
from oscar.apps.catalogue.models import Product, ProductClass, Category
|
|
7
|
|
-from oscar.apps.catalogue.utils import breadcrumbs_to_category
|
|
|
7
|
+from oscar.apps.catalogue.categories import create_from_breadcrumbs
|
|
8
|
8
|
|
|
9
|
9
|
|
|
10
|
10
|
class CategoryTests(TestCase):
|
|
|
11
|
+
|
|
|
12
|
+ def setUp(self):
|
|
|
13
|
+ Category.objects.all().delete()
|
|
11
|
14
|
|
|
12
|
|
- def test_create_category_root(self):
|
|
|
15
|
+ def test_creating_category_root(self):
|
|
13
|
16
|
trail = 'Books'
|
|
14
|
|
- category = breadcrumbs_to_category(trail)
|
|
|
17
|
+ category = create_from_breadcrumbs(trail)
|
|
15
|
18
|
self.assertIsNotNone(category)
|
|
16
|
19
|
self.assertEquals(category.name, 'Books')
|
|
17
|
20
|
self.assertEquals(category.slug, 'books')
|
|
18
|
21
|
|
|
19
|
|
- def test_subcategory(self):
|
|
|
22
|
+ def test_creating_parent_and_child_categories(self):
|
|
20
|
23
|
trail = 'Books > Science-Fiction'
|
|
21
|
|
- category = breadcrumbs_to_category(trail)
|
|
|
24
|
+ category = create_from_breadcrumbs(trail)
|
|
22
|
25
|
|
|
23
|
26
|
self.assertIsNotNone(category)
|
|
24
|
27
|
self.assertEquals(category.name, 'Science-Fiction')
|
|
|
@@ -27,11 +30,11 @@ class CategoryTests(TestCase):
|
|
27
|
30
|
self.assertEquals(2, Category.objects.count())
|
|
28
|
31
|
self.assertEquals(category.slug, 'books/science-fiction')
|
|
29
|
32
|
|
|
30
|
|
- def test_subsubcategory(self):
|
|
|
33
|
+ def test_creating_multiple_categories(self):
|
|
31
|
34
|
trail = 'Books > Science-Fiction > Star Trek'
|
|
32
|
|
- breadcrumbs_to_category(trail)
|
|
|
35
|
+ create_from_breadcrumbs(trail)
|
|
33
|
36
|
trail = 'Books > Factual > Popular Science'
|
|
34
|
|
- category = breadcrumbs_to_category(trail)
|
|
|
37
|
+ category = create_from_breadcrumbs(trail)
|
|
35
|
38
|
|
|
36
|
39
|
self.assertIsNotNone(category)
|
|
37
|
40
|
self.assertEquals(category.name, 'Popular Science')
|
|
|
@@ -40,6 +43,10 @@ class CategoryTests(TestCase):
|
|
40
|
43
|
self.assertEquals(5, Category.objects.count())
|
|
41
|
44
|
self.assertEquals(category.slug, 'books/factual/popular-science', )
|
|
42
|
45
|
|
|
|
46
|
+ def test_alternative_separator_can_be_used(self):
|
|
|
47
|
+ trail = 'Food|Cheese|Blue'
|
|
|
48
|
+ create_from_breadcrumbs(trail, separator='|')
|
|
|
49
|
+ self.assertEquals(3, len(Category.objects.all()))
|
|
43
|
50
|
|
|
44
|
51
|
class ItemTests(TestCase):
|
|
45
|
52
|
|