conftest.py 878 B

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