New tests for memgraph, every test scenario creates its own db driver.
Reviewers: buda Reviewed By: buda Subscribers: matej.gradicek Differential Revision: https://phabricator.memgraph.io/D198
This commit is contained in:
parent
a07bb48a7a
commit
54f4a7496d
@ -14,15 +14,18 @@ def before_scenario(context, step):
|
||||
context.test_parameters = TestParameters()
|
||||
context.graph_properties = GraphProperties()
|
||||
context.exception = None
|
||||
context.driver = create_db_driver(context)
|
||||
context.session = context.driver.session()
|
||||
|
||||
|
||||
def after_scenario(context, scenario):
|
||||
test_results.add_test(scenario.status)
|
||||
context.session.close()
|
||||
|
||||
|
||||
|
||||
def before_all(context):
|
||||
set_logging(context)
|
||||
context.driver = create_db_driver(context)
|
||||
|
||||
|
||||
def after_all(context):
|
||||
|
@ -11,11 +11,10 @@ def query(q, context, params={}):
|
||||
@return:
|
||||
List of query results.
|
||||
"""
|
||||
driver = context.driver
|
||||
results_list = []
|
||||
|
||||
if context.config.database == "neo4j":
|
||||
session = driver.session()
|
||||
session = context.session
|
||||
try:
|
||||
# executing query
|
||||
results = session.run(q, params)
|
||||
@ -35,12 +34,10 @@ def query(q, context, params={}):
|
||||
This code snippet should replace code which is now
|
||||
executing queries when session.transactions will be supported.
|
||||
"""
|
||||
session.close()
|
||||
except Exception as e:
|
||||
# exception
|
||||
context.exception = e
|
||||
context.log.info('%s', str(e))
|
||||
session.close()
|
||||
# not working if removed
|
||||
query("match (n) detach delete(n)", context)
|
||||
return results_list
|
||||
|
326
tck_engine/tests/memgraph_V1/features/test02.feature
Normal file
326
tck_engine/tests/memgraph_V1/features/test02.feature
Normal file
@ -0,0 +1,326 @@
|
||||
Feature: Test02
|
||||
|
||||
Scenario: Match create return test
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:x_1), (:z2_), (:qw34)
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:x_1), (b:z2_), (c:qw34)
|
||||
CREATE (a)-[x:X]->(b) CREATE (b)<-[y:Y]-(c)
|
||||
RETURN x, y
|
||||
"""
|
||||
Then the result should be:
|
||||
| x | y |
|
||||
| [:X] | [:Y] |
|
||||
|
||||
Scenario: Multiple matches in one query
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:x{age: 5}), (:y{age: 4}), (:z), (:x), (:y)
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:x), (b:y), (c:z)
|
||||
WHERE a.age=5
|
||||
MATCH (b{age: 4})
|
||||
RETURN a, b, c
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b | c |
|
||||
| (:x{age: 5}) | (:y{age: 4}) | (:z) |
|
||||
|
||||
Scenario: Match set one property return test
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:q)-[:X]->()
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:q)-[b]-(c)
|
||||
SET a.name='Sinisa'
|
||||
RETURN a, b, c
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b | c |
|
||||
| (:q{name: 'Sinisa'}) | [:X] | () |
|
||||
|
||||
Scenario: Match set properties from node to node return test
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:q{name: 'Sinisa', x: 'y'})-[:X]->({name: 'V', desc: 'Traktor'})
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:q)-[b]-(c)
|
||||
SET c=a
|
||||
RETURN a, b, c
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b | c |
|
||||
| (:q{name: 'Sinisa', x: 'y'}) | [:X] | ({name: 'Sinisa', x: 'y'}) |
|
||||
|
||||
Scenario: Match set properties from node to relationship return test
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:q{x: 'y'})-[:X]->({y: 't'})
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:q)-[b]-(c)
|
||||
SET b=a
|
||||
RETURN a, b, c
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b | c |
|
||||
| (:q{x: 'y'}) | [:X{x: 'y'}] | ({y: 't'}) |
|
||||
|
||||
Scenario: Match set properties from relationship to node return test
|
||||
Given an empty graph
|
||||
And having executed
|
||||
"""
|
||||
CREATE (:q)-[:X{x: 'y'}]->({y: 't'})
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (a:q)-[b]-(c)
|
||||
SET a=b
|
||||
RETURN a, b, c
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b | c |
|
||||
| (:q{x: 'y'}) | [:X{x: 'y'}] | ({y: 't'}) |
|
||||
|
||||
Scenario: Match, set properties from relationship to relationship, return test
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
CREATE ()-[b:X{x: 'y'}]->()-[a:Y]->()
|
||||
SET a=b
|
||||
RETURN a, b
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b |
|
||||
| [:Y{x: 'y'}] | [:X{x: 'y'}] |
|
||||
|
||||
Scenario: Create, set adding properties, return test
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
CREATE ()-[b:X{x: 'y', y: 'z'}]->()-[a:Y{x: 'z'}]->()
|
||||
SET a += b
|
||||
RETURN a, b
|
||||
"""
|
||||
Then the result should be:
|
||||
| a | b |
|
||||
| [:Y{x: 'y', y: 'z'}] | [:X{x: 'y', y: 'z'}] |
|
||||
|
||||
Scenario: Create node and add labels using set, return test
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
CREATE (a)
|
||||
SET a :sinisa:vu
|
||||
RETURN a
|
||||
"""
|
||||
Then the result should be:
|
||||
| a |
|
||||
| (:sinisa:vu) |
|
||||
|
||||
|
||||
|
||||
|
||||
Scenario: Create node and delete it
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
"""
|
||||
CREATE (n)
|
||||
DELETE (n)
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (n)
|
||||
RETURN n
|
||||
"""
|
||||
Then the result should be empty
|
||||
|
||||
Scenario: Create node with relationships and delete it, check for relationships
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
"""
|
||||
CREATE (n)-[:X]->()
|
||||
CREATE (n)-[:Y]->()
|
||||
DETACH DELETE (n)
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH ()-[n]->()
|
||||
RETURN n
|
||||
"""
|
||||
Then the result should be empty
|
||||
|
||||
Scenario: Create node with relationships and delete it, check for nodes
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
"""
|
||||
CREATE (n:l{a: 1})-[:X]->()
|
||||
CREATE (n)-[:Y]->()
|
||||
DETACH DELETE (n)
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (n)
|
||||
RETURN n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
|( )|
|
||||
|( )|
|
||||
|
||||
|
||||
|
||||
Scenario: Test equal operator
|
||||
When executing query:
|
||||
"""
|
||||
CREATE (a)
|
||||
RETURN 1=1 and 1.0=1.0 and 'abc'='abc' and false=false and a.age is null as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test not equal operator
|
||||
When executing query:
|
||||
"""
|
||||
CREATE (a{age: 1})
|
||||
RETURN not 1<>1 and 1.0<>1.1 and 'abcd'<>'abc' and false<>true and a.age is not null as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test greater operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 2>1 and not 1.0>1.1 and 'abcd'>'abc' as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test less operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN not 2<1 and 1.0<1.1 and not 'abcd'<'abc' as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test greater equal operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 2>=2 and not 1.0>=1.1 and 'abcd'>='abc' as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test less equal operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 2<=2 and 1.0<=1.1 and not 'abcd'<='abc' as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
|
||||
|
||||
|
||||
Scenario: Test plus operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3+2=1.09+3.91 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test minus operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3-2=1.09-0.09 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test multiply operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3*2=1.5*4 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test divide operator1
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3/2<>7.5/5 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test divide operator2
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3.0/2=7.5/5 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test mod operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3%2=1 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test exponential operator
|
||||
When executing query:
|
||||
"""
|
||||
RETURN 3^2=81^0.5 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test one big mathematical equation
|
||||
When executing query:
|
||||
"""
|
||||
RETURN (3+2*4-3/2%2*10)/5.0^2.0=0.04 as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| true |
|
||||
|
||||
Scenario: Test one big logical equation
|
||||
When executing query:
|
||||
"""
|
||||
RETURN not true or true and false or not ((true xor false or true) and true or false xor true ) as n
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| false |
|
Loading…
Reference in New Issue
Block a user