-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into n+1-sql-queries
- Loading branch information
Showing
23 changed files
with
8,407 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib.auth.models import Group | ||
from django.test import TestCase | ||
|
||
from zds.forum.tests.factories import create_category_and_forum | ||
from zds.forum.utils import get_authorized_forums_pk | ||
from zds.member.tests.factories import ProfileFactory, StaffProfileFactory | ||
|
||
|
||
class GetAuthorizedForumsTests(TestCase): | ||
def test_get_authorized_forums_pk(self): | ||
user = ProfileFactory().user | ||
staff = StaffProfileFactory().user | ||
|
||
# 1. Create a hidden forum belonging to a hidden staff group: | ||
group = Group.objects.create(name="Les illuminatis anonymes de ZdS") | ||
_, hidden_forum = create_category_and_forum(group) | ||
|
||
staff.groups.add(group) | ||
staff.save() | ||
|
||
# 2. Create a public forum: | ||
_, public_forum = create_category_and_forum() | ||
|
||
# 3. Regular user can access only the public forum: | ||
self.assertEqual(get_authorized_forums_pk(user), [public_forum.pk]) | ||
|
||
# 4. Staff user can access all forums: | ||
self.assertEqual(sorted(get_authorized_forums_pk(staff)), sorted([hidden_forum.pk, public_forum.pk])) | ||
|
||
# 5. By default, only public forums are available: | ||
self.assertEqual(get_authorized_forums_pk(None), [public_forum.pk]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,17 @@ def test_username_slash_register_form(self): | |
form = RegisterForm(data=data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_username_character_null(self): | ||
ProfileFactory() | ||
data = { | ||
"email": "[email protected]", | ||
"username": "foo\x00bar", | ||
"password": "ZePassword", | ||
"password_confirm": "ZePassword", | ||
} | ||
form = RegisterForm(data=data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
|
||
class UnregisterFormTest(TestCase): | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.