app.py 674 B

1234567891011121314151617181920212223242526272829303132333435
  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. @pytest.yield_fixture(autouse=True)
  7. def application():
  8. """application with context."""
  9. app = create_app(Config)
  10. ctx = app.app_context()
  11. ctx.push()
  12. yield app
  13. ctx.pop()
  14. @pytest.fixture()
  15. def default_groups():
  16. """Creates the default groups"""
  17. return create_default_groups()
  18. @pytest.yield_fixture()
  19. def database(default_groups):
  20. """database setup."""
  21. db.create_all() # Maybe use migration instead?
  22. yield db
  23. db.drop_all()