-
-
Save hvdklauw/9686872 to your computer and use it in GitHub Desktop.
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
import pytest | |
from flaskbb.user.models import User | |
from flaskbb.forum.models import Forum, Category | |
@pytest.fixture | |
def category(database): | |
category = Category(title="Test Category") | |
category.save() | |
return category | |
@pytest.fixture | |
def forum(category): | |
forum = Forum(title="Test Forum", category_id=category.id) | |
forum.save() | |
return forum | |
@pytest.fixture | |
def moderator_user(forum, default_groups): | |
"""Creates a test user for whom the permissions should be checked""" | |
# This should be moved to own fixture which you then use to link the user to the forum | |
user = User(username="test_mod", email="[email protected]", | |
password="test", primary_group_id=default_groups[2].id) | |
user.save() | |
forum.moderators.append(user) | |
forum.save() | |
return user | |
@pytest.fixture | |
def normal_user(default_groups): | |
"""Creates a user with normal permissions""" | |
user = User(username="test_normal", email="[email protected]", | |
password="test", primary_group_id=default_groups[3].id) | |
user.save() | |
return user | |
@pytest.fixture | |
def admin_user(default_groups): | |
"""Creates a admin user""" | |
user = User(username="test_admin", email="[email protected]", | |
password="test", primary_group_id=default_groups[0].id) | |
user.save() | |
return user | |
def test_moderator_permissions(forum, moderator_user): | |
"""Test that the default groups are created correctly.""" | |
assert moderator_user in forum.moderators |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment