Improve tests
This commit is contained in:
parent
2ef9d81a63
commit
c7be58e1dc
@ -49,8 +49,12 @@ def memgraph(**kwargs) -> Memgraph:
|
|||||||
def memgraph_with_text_indexed_data(**kwargs) -> Memgraph:
|
def memgraph_with_text_indexed_data(**kwargs) -> Memgraph:
|
||||||
memgraph = Memgraph()
|
memgraph = Memgraph()
|
||||||
|
|
||||||
memgraph.execute("CREATE (:Document {title: 'Rules2024', version: 1});")
|
memgraph.execute(
|
||||||
memgraph.execute("CREATE (:Document:Revision {title: 'Rules2024', version: 2});")
|
"CREATE (:Document {title: 'Rules2024', version: 1, date: date('2023-11-14'), contents: 'Lorem ipsum dolor sit amet'});"
|
||||||
|
)
|
||||||
|
memgraph.execute(
|
||||||
|
"CREATE (:Document:Revision {title: 'Rules2024', version: 2, date: date('2023-12-15'), contents: 'consectetur adipiscing elit'});"
|
||||||
|
)
|
||||||
memgraph.execute("CREATE TEXT INDEX complianceDocuments ON :Document;")
|
memgraph.execute("CREATE TEXT INDEX complianceDocuments ON :Document;")
|
||||||
|
|
||||||
yield memgraph
|
yield memgraph
|
||||||
@ -64,8 +68,12 @@ def memgraph_with_text_indexed_data(**kwargs) -> Memgraph:
|
|||||||
def memgraph_with_mixed_data(**kwargs) -> Memgraph:
|
def memgraph_with_mixed_data(**kwargs) -> Memgraph:
|
||||||
memgraph = Memgraph()
|
memgraph = Memgraph()
|
||||||
|
|
||||||
memgraph.execute("CREATE (:Document:Revision {title: 'Rules2024', version: 1});")
|
memgraph.execute(
|
||||||
memgraph.execute("CREATE (:Revision {title: 'Rules2024', version: 2});")
|
"CREATE (:Document:Revision {title: 'Rules2024', version: 1, date: date('2023-11-14'), contents: 'Lorem ipsum dolor sit amet'});"
|
||||||
|
)
|
||||||
|
memgraph.execute(
|
||||||
|
"CREATE (:Revision {title: 'Rules2024', version: 2, date: date('2023-12-15'), contents: 'consectetur adipiscing elit'});"
|
||||||
|
)
|
||||||
memgraph.execute("CREATE TEXT INDEX complianceDocuments ON :Document;")
|
memgraph.execute("CREATE TEXT INDEX complianceDocuments ON :Document;")
|
||||||
|
|
||||||
yield memgraph
|
yield memgraph
|
||||||
|
@ -42,19 +42,14 @@ def test_text_search_given_property(memgraph_with_text_indexed_data):
|
|||||||
assert len(result) == 2 and result == [{"title": "Rules2024", "version": 1}, {"title": "Rules2024", "version": 2}]
|
assert len(result) == 2 and result == [{"title": "Rules2024", "version": 1}, {"title": "Rules2024", "version": 2}]
|
||||||
|
|
||||||
|
|
||||||
# def test_text_search_all_properties(memgraph_with_text_indexed_data):
|
# def test_text_search_query_boolean(memgraph_with_text_indexed_data):
|
||||||
# # issue
|
# BOOLEAN_QUERY = """CALL text_search.search('complianceDocuments', '(data.title:Rules2023 OR data.title:Rules2024) AND data.contents:consectetur') YIELD node
|
||||||
# result = list(memgraph_with_text_indexed_data.execute_and_fetch(GET_RULES_2024_DOCUMENT))
|
# RETURN node.title AS title, node.version AS version
|
||||||
# print(result)
|
# ORDER BY version ASC, title ASC;"""
|
||||||
# result = list(
|
|
||||||
# memgraph_with_text_indexed_data.execute_and_fetch(
|
|
||||||
# """CALL text_search.search('complianceDocuments', 'Rules2024') YIELD node
|
|
||||||
# RETURN node.title AS title, node.version AS version
|
|
||||||
# ORDER BY version ASC, title ASC;"""
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
||||||
# assert len(result) == 2 and result == [{"title": "Rules2024", "version": 1}, {"title": "Rules2024", "version": 2}]
|
# result = list(memgraph_with_text_indexed_data.execute_and_fetch(BOOLEAN_QUERY))
|
||||||
|
|
||||||
|
# assert len(result) == 1 and result == [{"title": "Rules2024", "version": 2}]
|
||||||
|
|
||||||
|
|
||||||
def test_create_indexed_node(memgraph_with_text_indexed_data):
|
def test_create_indexed_node(memgraph_with_text_indexed_data):
|
||||||
@ -109,16 +104,16 @@ def test_update_text_property_of_indexed_node(memgraph_with_text_indexed_data):
|
|||||||
|
|
||||||
|
|
||||||
def test_add_non_text_property_to_indexed_node(memgraph_with_text_indexed_data):
|
def test_add_non_text_property_to_indexed_node(memgraph_with_text_indexed_data):
|
||||||
memgraph_with_text_indexed_data.execute("MATCH (n:Document {version:1}) SET n.wordcount = 1926;")
|
memgraph_with_text_indexed_data.execute("MATCH (n:Document {version:1}) SET n.randomList = [2, 3, 4, 5];")
|
||||||
|
|
||||||
|
|
||||||
def test_remove_text_property_from_indexed_node(memgraph_with_text_indexed_data):
|
def test_remove_text_property_from_indexed_node(memgraph_with_text_indexed_data):
|
||||||
with pytest.raises(GQLAlchemyDatabaseError, match="Tantivy error.*Please check mappings.") as e:
|
with pytest.raises(GQLAlchemyDatabaseError, match="Tantivy error.*Please check mappings.") as e:
|
||||||
memgraph_with_text_indexed_data.execute("MATCH (n:Document {version:1}) REMOVE n.title;")
|
memgraph_with_text_indexed_data.execute("MATCH (n:Document {version:1}) REMOVE n.title, n.version, n.contents;")
|
||||||
|
|
||||||
|
|
||||||
def test_remove_non_text_property_from_indexed_node(memgraph_with_text_indexed_data):
|
def test_remove_non_text_property_from_indexed_node(memgraph_with_text_indexed_data):
|
||||||
memgraph_with_text_indexed_data.execute_and_fetch("MATCH (n:Document {version:1}) REMOVE n.version;")
|
memgraph_with_text_indexed_data.execute_and_fetch("MATCH (n:Document {date: date('2023-12-15')}) REMOVE n.date;")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user