Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jun 18, 2024
1 parent 81588a7 commit e580baf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions misago/categories/admin/tests/test_permissions_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test_change_category_roles_view(self):
data={
"name": "Category A",
"new_parent": root.pk,
"children_categories_component": "full",
"prune_started_after": 0,
"prune_replied_after": 0,
},
Expand Down Expand Up @@ -251,11 +252,12 @@ def test_change_role_categories_permissions_view(self):
# + Category D

root = Category.objects.root_category()
self.client.post(
a = self.client.post(
reverse("misago:admin:categories:new"),
data={
"name": "Category A",
"new_parent": root.pk,
"children_categories_component": "full",
"prune_started_after": 0,
"prune_replied_after": 0,
},
Expand All @@ -265,11 +267,11 @@ def test_change_role_categories_permissions_view(self):
data={
"name": "Category C",
"new_parent": root.pk,
"children_categories_component": "full",
"prune_started_after": 0,
"prune_replied_after": 0,
},
)

category_a = Category.objects.get(slug="category-a")
category_c = Category.objects.get(slug="category-c")

Expand All @@ -278,6 +280,7 @@ def test_change_role_categories_permissions_view(self):
data={
"name": "Category B",
"new_parent": category_a.pk,
"children_categories_component": "full",
"prune_started_after": 0,
"prune_replied_after": 0,
},
Expand All @@ -289,6 +292,7 @@ def test_change_role_categories_permissions_view(self):
data={
"name": "Category D",
"new_parent": category_c.pk,
"children_categories_component": "full",
"prune_started_after": 0,
"prune_replied_after": 0,
},
Expand Down
18 changes: 18 additions & 0 deletions misago/categories/tests/test_get_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_get_categories_returns_all_categories_visible_by_user(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -55,6 +56,7 @@ def test_get_categories_returns_all_categories_visible_by_user(
"color": sibling_category.color,
"css_class": sibling_category.css_class,
"is_closed": sibling_category.is_closed,
"is_vanilla": sibling_category.is_vanilla,
"url": sibling_category.get_absolute_url(),
"lft": sibling_category.lft,
"rght": sibling_category.rght,
Expand All @@ -67,6 +69,7 @@ def test_get_categories_returns_all_categories_visible_by_user(
"color": child_category.color,
"css_class": child_category.css_class,
"is_closed": child_category.is_closed,
"is_vanilla": child_category.is_vanilla,
"url": child_category.get_absolute_url(),
"lft": child_category.lft,
"rght": child_category.rght,
Expand All @@ -79,6 +82,7 @@ def test_get_categories_returns_all_categories_visible_by_user(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand Down Expand Up @@ -120,6 +124,7 @@ def test_get_categories_uses_delay_browse_check_for_child_category(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -132,6 +137,7 @@ def test_get_categories_uses_delay_browse_check_for_child_category(
"color": sibling_category.color,
"css_class": sibling_category.css_class,
"is_closed": sibling_category.is_closed,
"is_vanilla": sibling_category.is_vanilla,
"url": sibling_category.get_absolute_url(),
"lft": sibling_category.lft,
"rght": sibling_category.rght,
Expand All @@ -144,6 +150,7 @@ def test_get_categories_uses_delay_browse_check_for_child_category(
"color": child_category.color,
"css_class": child_category.css_class,
"is_closed": child_category.is_closed,
"is_vanilla": child_category.is_vanilla,
"url": child_category.get_absolute_url(),
"lft": child_category.lft,
"rght": child_category.rght,
Expand All @@ -156,6 +163,7 @@ def test_get_categories_uses_delay_browse_check_for_child_category(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand Down Expand Up @@ -189,6 +197,7 @@ def test_get_categories_excludes_categories_invisible_to_user(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -201,6 +210,7 @@ def test_get_categories_excludes_categories_invisible_to_user(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand Down Expand Up @@ -236,6 +246,7 @@ def test_get_categories_excludes_special_categories(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -248,6 +259,7 @@ def test_get_categories_excludes_special_categories(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand Down Expand Up @@ -276,6 +288,7 @@ def test_get_categories_skips_database_read_if_there_is_cache(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -295,6 +308,7 @@ def test_get_categories_skips_database_read_if_there_is_cache(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand Down Expand Up @@ -337,6 +351,7 @@ def test_get_categories_is_cached_when_database_is_used(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -349,6 +364,7 @@ def test_get_categories_is_cached_when_database_is_used(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand All @@ -366,6 +382,7 @@ def test_get_categories_is_cached_when_database_is_used(
"color": default_category.color,
"css_class": default_category.css_class,
"is_closed": default_category.is_closed,
"is_vanilla": default_category.is_vanilla,
"url": default_category.get_absolute_url(),
"lft": default_category.lft,
"rght": default_category.rght,
Expand All @@ -378,6 +395,7 @@ def test_get_categories_is_cached_when_database_is_used(
"color": other_category.color,
"css_class": other_category.css_class,
"is_closed": other_category.is_closed,
"is_vanilla": other_category.is_vanilla,
"url": other_category.get_absolute_url(),
"lft": other_category.lft,
"rght": other_category.rght,
Expand Down

0 comments on commit e580baf

Please sign in to comment.