test_populate.py 700 B

1234567891011121314151617181920212223242526
  1. import pytest
  2. from flaskbb.utils.populate import create_default_groups, GROUPS
  3. from flaskbb.user.models import Group
  4. @pytest.fixture()
  5. def default_groups():
  6. """Overwrite for the default fixture, in this case we don't want the default groups created."""
  7. return []
  8. def test_create_default_groups(database):
  9. """Test that the default groups are created correctly."""
  10. assert Group.query.count() == 0
  11. create_default_groups()
  12. assert Group.query.count() == len(GROUPS)
  13. for key, attributes in GROUPS.items():
  14. group = Group.query.filter_by(name=key).first()
  15. for attribute, value in attributes.items():
  16. assert getattr(group, attribute) == value