haystack/test/test_db.py

12 lines
525 B
Python
Raw Normal View History

2020-01-22 16:08:52 +01:00
from haystack.database.sql import SQLDocumentStore
from haystack.indexing.io import write_documents_to_db
2019-11-27 17:53:42 +01:00
def test_db_write_read():
2020-01-22 16:08:52 +01:00
sql_datastore = SQLDocumentStore()
write_documents_to_db(datastore=sql_datastore, document_dir="samples/docs")
documents = sql_datastore.get_all_documents()
2019-11-27 17:53:42 +01:00
assert len(documents) == 2
2020-01-23 09:18:15 +01:00
doc = sql_datastore.get_document_by_id("1")
assert doc["text"] == 'A Doc specifically talking about haystack.\nHaystack can be used to scale QA models to large document collections.'