Fix tests

This commit is contained in:
Tanay Soni 2020-01-22 16:08:52 +01:00
parent ecfd19d2d8
commit 845062ce2d

View File

@ -1,13 +1,10 @@
from haystack.indexing.io import write_documents_to_db, fetch_archive_from_http
from haystack.database.orm import Document
from haystack.database.sql import SQLDocumentStore
from haystack.indexing.io import write_documents_to_db
def test_db_write_read():
from haystack.database import db
db.drop_all()
db.create_all()
write_documents_to_db(document_dir="samples/docs")
documents = db.session.query(Document).order_by(Document.text).all()
sql_datastore = SQLDocumentStore()
write_documents_to_db(datastore=sql_datastore, document_dir="samples/docs")
documents = sql_datastore.get_all_documents()
assert len(documents) == 2
assert documents[0].text == 'A Doc specifically talking about haystack.\nHaystack can be used to scale QA models to large document collections.'
assert documents[0]["text"] == 'A Doc specifically talking about haystack.\nHaystack can be used to scale QA models to large document collections.'