conftest.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. db.ds.default_context.parse(source='data/bootstrap/simple_layout.nq',
  27. format='nquads')
  28. db.store.commit()
  29. yield db
  30. print('Tearing down fixure graph store.')
  31. for g in db.ds.graphs():
  32. db.ds.remove_graph(g)
  33. db.store.commit()
  34. @pytest.fixture
  35. def rnd_img():
  36. '''
  37. Generate a square image with random color tiles.
  38. '''
  39. return random_image(8, 256)