forum.py 969 B

1234567891011121314151617181920212223242526272829303132333435
  1. import pytest
  2. from flaskbb.forum.models import Forum, Category, Topic, Post
  3. @pytest.fixture
  4. def category(database):
  5. """A single category."""
  6. category = Category(title="Test Category")
  7. category.save()
  8. return category
  9. @pytest.fixture
  10. def forum(category, default_settings):
  11. """A single forum in a category."""
  12. forum = Forum(title="Test Forum", category_id=category.id)
  13. forum.save()
  14. return forum
  15. @pytest.fixture
  16. def topic(forum, user):
  17. """A topic by a normal user without any extra permissions."""
  18. topic = Topic(title="Test Topic Normal")
  19. post = Post(content="Test Content Normal")
  20. return topic.save(forum=forum, user=user, post=post)
  21. @pytest.fixture
  22. def topic_moderator(forum, moderator_user):
  23. """A topic by a user with moderator permissions."""
  24. topic = Topic(title="Test Topic Moderator")
  25. post = Post(content="Test Content Moderator")
  26. return topic.save(forum=forum, user=moderator_user, post=post)