@@ -16,16 +16,38 @@ class TestPublishedCategories(WebTest):
16
16
def setUp (self ):
17
17
self .user = UserFactory ()
18
18
self .published1 = CategoryFactory (
19
- path = "0001" , name = "First one" , slug = "first-one"
19
+ path = "0001" ,
20
+ name = "First one" ,
21
+ slug = "first-one" ,
22
+ visible_for_anonymous = True ,
23
+ visible_for_authenticated = True ,
20
24
)
21
25
self .published2 = CategoryFactory (
22
- path = "0002" , name = "Second one" , slug = "second-one"
26
+ path = "0002" ,
27
+ name = "Second one" ,
28
+ slug = "second-one" ,
29
+ visible_for_anonymous = True ,
30
+ visible_for_authenticated = False ,
31
+ )
32
+ self .published3 = CategoryFactory (
33
+ path = "0003" ,
34
+ name = "Third one" ,
35
+ slug = "third-one" ,
36
+ visible_for_anonymous = False ,
37
+ visible_for_authenticated = True ,
38
+ )
39
+ self .published4 = CategoryFactory (
40
+ path = "0004" ,
41
+ name = "Fourth one" ,
42
+ slug = "fourth-one" ,
43
+ visible_for_anonymous = False ,
44
+ visible_for_authenticated = False ,
23
45
)
24
46
self .draft1 = CategoryFactory (
25
- path = "0003 " , name = "Third one" , slug = "third -one" , published = False
47
+ path = "0005 " , name = "Fifth one" , slug = "fifth -one" , published = False
26
48
)
27
49
self .draft2 = CategoryFactory (
28
- path = "0004 " , name = "Wourth one" , slug = "wourth -one" , published = False
50
+ path = "0006 " , name = "Sixth one" , slug = "sixth -one" , published = False
29
51
)
30
52
cms_tools .create_homepage ()
31
53
@@ -40,7 +62,7 @@ def test_only_published_categories_exist_in_breadcrumbs_when_logged_in(self):
40
62
response = self .app .get ("/" , user = self .user )
41
63
self .assertEqual (
42
64
list (response .context ["menu_categories" ]),
43
- [self .published1 , self .published2 ],
65
+ [self .published1 , self .published3 ],
44
66
)
45
67
46
68
def test_only_published_categories_exist_in_list_page_when_anonymous (self ):
@@ -52,7 +74,7 @@ def test_only_published_categories_exist_in_list_page_when_anonymous(self):
52
74
def test_only_published_categories_exist_in_list_page_when_logged_in (self ):
53
75
response = self .app .get (reverse ("products:category_list" ), user = self .user )
54
76
self .assertEqual (
55
- list (response .context ["categories" ]), [self .published1 , self .published2 ]
77
+ list (response .context ["categories" ]), [self .published1 , self .published3 ]
56
78
)
57
79
58
80
def test_only_published_subcategories_exist_in_detail_page_when_anonymous (self ):
@@ -87,7 +109,7 @@ def test_only_published_categories_exist_in_my_categories_page(self):
87
109
response = self .app .get (reverse ("profile:categories" ), user = self .user )
88
110
self .assertEqual (
89
111
list (response .context ["form" ].fields ["selected_categories" ].queryset .all ()),
90
- [self .published1 , self .published2 ],
112
+ [self .published1 , self .published2 , self . published3 , self . published4 ],
91
113
)
92
114
93
115
0 commit comments