Add expandone test

This commit is contained in:
jbajic 2022-11-04 16:18:18 +01:00
parent bab5e1386a
commit e52ce1e363
3 changed files with 49 additions and 7 deletions

View File

@ -9,11 +9,11 @@
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.
import typing
import mgclient
import sys
import pytest
import time
from typing import List, Optional
import mgclient
import pytest
@pytest.fixture(autouse=True)
@ -28,12 +28,12 @@ def connect(**kwargs) -> mgclient.Connection:
return connection
def execute_and_fetch_all(cursor: mgclient.Cursor, query: str, params: dict = {}) -> typing.List[tuple]:
cursor.execute(query, params)
def execute_and_fetch_all(cursor: mgclient.Cursor, query: str, params: Optional[dict] = None) -> List[tuple]:
cursor.execute(query, params if params else {})
return cursor.fetchall()
def has_n_result_row(cursor: mgclient.Cursor, query: str, n: int):
def has_n_result_row(cursor: mgclient.Cursor, query: str, n: int) -> bool:
results = execute_and_fetch_all(cursor, query)
return len(results) == n

View File

@ -0,0 +1,37 @@
# Copyright 2022 Memgraph Ltd.
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
# License, and you may not use this file except in compliance with the Business Source License.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.
import sys
import pytest
from common import connection, execute_and_fetch_all, has_n_result_row, wait_for_shard_manager_to_initialize
def test_sequenced_expand_one(connection):
wait_for_shard_manager_to_initialize()
cursor = connection.cursor()
for i in range(1, 4):
assert has_n_result_row(cursor, f"CREATE (:label {{property:{i}}})", 0), f"Failed creating node"
assert has_n_result_row(cursor, "MATCH (n {property:1}), (m {property:2}) CREATE (n)-[:TO]->(m)", 0)
assert has_n_result_row(cursor, "MATCH (n {property:2}), (m {property:3}) CREATE (n)-[:TO]->(m)", 0)
results = execute_and_fetch_all(cursor, "MATCH (n)-[:TO]->(m)-[:TO]->(l) RETURN n,m,l")
assert len(results) == 1
n, m, l = results[0]
assert n.properties["property"] == 1
assert m.properties["property"] == 2
assert l.properties["property"] == 3
if __name__ == "__main__":
sys.exit(pytest.main([__file__, "-rA"]))

View File

@ -12,6 +12,11 @@ workloads:
args: ["distributed_queries/distributed_queries.py"]
<<: *template_cluster
- name: "Distributed expand one"
binary: "tests/e2e/pytest_runner.sh"
args: ["distributed_queries/distributed_expand_one.py"]
<<: *template_cluster
- name: "Distributed unwind collect"
binary: "tests/e2e/pytest_runner.sh"
args: ["distributed_queries/unwind_collect.py"]