conftest.py 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import sys
  2. import pytest
  3. sys.path.append('.')
  4. from lakesuperior.config_parser import test_config
  5. from lakesuperior.globals import AppGlobals
  6. from lakesuperior.env import env
  7. env.config = test_config
  8. env.app_globals = AppGlobals(test_config)
  9. from lakesuperior.app import create_app
  10. from lakesuperior.util.generators import random_image
  11. env.config = test_config
  12. @pytest.fixture(scope='module')
  13. def app():
  14. app = create_app(env.config['application'])
  15. yield app
  16. @pytest.fixture(scope='module')
  17. def db(app):
  18. '''
  19. Set up and tear down test triplestore.
  20. '''
  21. rdfly = env.app_globals.rdfly
  22. rdfly.bootstrap()
  23. env.app_globals.nonrdfly.bootstrap()
  24. yield rdfly
  25. print('Tearing down fixture graph store.')
  26. rdfly.store.destroy(rdfly.store.path)
  27. @pytest.fixture
  28. def rnd_img():
  29. '''
  30. Generate a square image with random color tiles.
  31. '''
  32. return random_image(8, 256)