@@ -693,3 +693,40 @@ def test_text_search_fuzzy(client):
693693 client .drop_text_index (idx_name )
694694 finally :
695695 client .cypher (f"MATCH (n:{ label } {{tag: $tag}}) DELETE n" , params = {"tag" : tag })
696+
697+
698+ def test_cypher_accepts_consistency_kwargs (client ):
699+ """cypher() wires read_concern / write_concern / read_preference / after_index into the request."""
700+ # Write with majority concern then read back with majority + primary + after_index.
701+ label = f"ConsistencyTest_{ uid ()} "
702+ tag = uid ()
703+ client .cypher (
704+ f"CREATE (n:{ label } {{tag: $tag, v: 1}})" ,
705+ params = {"tag" : tag },
706+ write_concern = "majority" ,
707+ )
708+ rows = client .cypher (
709+ f"MATCH (n:{ label } {{tag: $tag}}) RETURN n.v AS v" ,
710+ params = {"tag" : tag },
711+ read_concern = "majority" ,
712+ read_preference = "primary" ,
713+ after_index = 0 ,
714+ )
715+ try :
716+ assert rows and rows [0 ]["v" ] == 1
717+ finally :
718+ client .cypher (f"MATCH (n:{ label } {{tag: $tag}}) DELETE n" , params = {"tag" : tag })
719+
720+
721+ def test_cypher_rejects_invalid_consistency_values (client ):
722+ """Invalid consistency kwargs raise ValueError before the RPC."""
723+ import pytest as _pytest
724+
725+ with _pytest .raises (ValueError , match = "invalid read_concern" ):
726+ client .cypher ("RETURN 1" , read_concern = "strong" )
727+ with _pytest .raises (ValueError , match = "invalid write_concern" ):
728+ client .cypher ("RETURN 1" , write_concern = "w9" )
729+ with _pytest .raises (ValueError , match = "invalid read_preference" ):
730+ client .cypher ("RETURN 1" , read_preference = "leader" )
731+ with _pytest .raises (ValueError , match = "after_index must be a non-negative integer" ):
732+ client .cypher ("RETURN 1" , after_index = - 1 )
0 commit comments