conftest.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import sys
  2. sys.path.append('.')
  3. import numpy
  4. import random
  5. import uuid
  6. import pytest
  7. from PIL import Image
  8. from lakesuperior.app import create_app
  9. from lakesuperior.config_parser import config
  10. from lakesuperior.store_layouts.rdf.graph_store_connector import \
  11. GraphStoreConnector
  12. from util.generators import random_image
  13. @pytest.fixture(scope='module')
  14. def app():
  15. app = create_app(config['test'], config['logging'])
  16. yield app
  17. @pytest.fixture(scope='module')
  18. def db(app):
  19. '''
  20. Set up and tear down test triplestore.
  21. '''
  22. dbconf = app.config['store']['ldp_rs']
  23. db = GraphStoreConnector(
  24. query_ep=dbconf['webroot'] + dbconf['query_ep'],
  25. update_ep=dbconf['webroot'] + dbconf['update_ep'],
  26. autocommit=True)
  27. db.ds.default_context.parse(source='data/bootstrap/simple_layout.nq',
  28. format='nquads')
  29. yield db
  30. print('Tearing down fixure graph store.')
  31. for g in db.ds.graphs():
  32. db.ds.remove_graph(g)
  33. @pytest.fixture
  34. def rnd_img():
  35. '''
  36. Generate a square image with random color tiles.
  37. '''
  38. return random_image(8, 256)