app.py 827 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import pytest
  2. from flaskbb import create_app
  3. from flaskbb.extensions import db
  4. from flaskbb.configs.testing import TestingConfig as Config
  5. from flaskbb.utils.populate import create_default_groups, \
  6. create_default_settings
  7. @pytest.yield_fixture(autouse=True)
  8. def application():
  9. """application with context."""
  10. app = create_app(Config)
  11. ctx = app.app_context()
  12. ctx.push()
  13. yield app
  14. ctx.pop()
  15. @pytest.fixture()
  16. def default_groups(database):
  17. """Creates the default groups"""
  18. return create_default_groups()
  19. @pytest.fixture()
  20. def default_settings(database):
  21. """Creates the default settings"""
  22. return create_default_settings()
  23. @pytest.yield_fixture()
  24. def database():
  25. """database setup."""
  26. db.create_all() # Maybe use migration instead?
  27. yield db
  28. db.drop_all()