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-24 18:24:07 +01:00
|
|
|
sql_document_store = SQLDocumentStore()
|
|
|
|
write_documents_to_db(document_store=sql_document_store, document_dir="samples/docs")
|
|
|
|
documents = sql_document_store.get_all_documents()
|
2019-11-27 17:53:42 +01:00
|
|
|
assert len(documents) == 2
|
2020-01-24 18:24:07 +01:00
|
|
|
doc = sql_document_store.get_document_by_id("1")
|
2020-01-23 15:25:42 +01:00
|
|
|
assert doc.keys() == {"id", "name", "text", "tags"}
|