conftest.py 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. sys.path.append('.')
  3. import uuid
  4. import pytest
  5. from lakesuperior.app import create_app
  6. from lakesuperior.config_parser import config
  7. from lakesuperior.store_layouts.rdf.graph_store_connector import \
  8. GraphStoreConnector
  9. @pytest.fixture(scope='module')
  10. def app():
  11. app = create_app(config['test'], config['logging'])
  12. yield app
  13. @pytest.fixture(scope='module')
  14. def db(app):
  15. '''
  16. Set up and tear down test triplestore.
  17. '''
  18. dbconf = app.config['store']['ldp_rs']
  19. db = GraphStoreConnector(
  20. query_ep=dbconf['webroot'] + dbconf['query_ep'],
  21. update_ep=dbconf['webroot'] + dbconf['update_ep'])
  22. db.ds.default_context.parse(source='data/bootstrap/simple_layout.nq',
  23. format='nquads')
  24. db.store.commit()
  25. yield db
  26. print('Tearing down fixure graph store.')
  27. for g in db.ds.graphs():
  28. db.ds.remove_graph(g)
  29. db.store.commit()