def test_memory_store_get_by_tags(): test_docs = [{ "name": "testing the finder 1", "text": "testing the finder with pyhton unit test 1", 'meta': { 'url': 'url' } }, { "name": "testing the finder 2", "text": "testing the finder with pyhton unit test 2", 'meta': { 'url': None } }, { "name": "testing the finder 3", "text": "testing the finder with pyhton unit test 3", 'meta': { 'url': 'url' } }] from haystack.database.memory import InMemoryDocumentStore document_store = InMemoryDocumentStore() document_store.write_documents(test_docs) docs = document_store.get_document_ids_by_tags({'has_url': 'false'}) assert docs == []
def test_memory_store_get_by_tag_lists_non_existent_tag(): test_docs = [ {"name": "testing the finder 1", "text": "testing the finder with pyhton unit test 1", 'meta': {'url': 'url'}, 'tags': [{'tag1': ["1"]}]}, ] from haystack.database.memory import InMemoryDocumentStore document_store = InMemoryDocumentStore() document_store.write_documents(test_docs) docs = document_store.get_document_ids_by_tags({'tag1': ["3"]}) assert docs == []
def test_memory_store_get_by_tag_lists_union(): test_docs = [{ "name": "testing the finder 1", "text": "testing the finder with pyhton unit test 1", 'meta': { 'url': 'url' }, 'tags': [{ 'tag2': ["1"] }] }, { "name": "testing the finder 2", "text": "testing the finder with pyhton unit test 2", 'meta': { 'url': None }, 'tags': [{ 'tag1': ['1'] }] }, { "name": "testing the finder 3", "text": "testing the finder with pyhton unit test 3", 'meta': { 'url': 'url' }, 'tags': [{ 'tag2': ["1", "2"] }] }] from haystack.database.memory import InMemoryDocumentStore document_store = InMemoryDocumentStore() document_store.write_documents(test_docs) docs = document_store.get_document_ids_by_tags({'tag2': ["1"]}) assert docs == [{ 'name': 'testing the finder 1', 'text': 'testing the finder with pyhton unit test 1', 'meta': { 'url': 'url' }, 'tags': [{ 'tag2': ['1'] }] }, { 'name': 'testing the finder 3', 'text': 'testing the finder with pyhton unit test 3', 'meta': { 'url': 'url' }, 'tags': [{ 'tag2': ['1', '2'] }] }]