1111@pytest .fixture (autouse = True , scope = "class" )
1212def run_around_tests (gds_with_cloud_setup : AuraGraphDataScience ) -> Generator [None , None , None ]:
1313 # Runs before each test
14+ gds_with_cloud_setup .set_database ("neo4j" )
1415 gds_with_cloud_setup .run_cypher (
1516 """
1617 CREATE
@@ -27,6 +28,7 @@ def run_around_tests(gds_with_cloud_setup: AuraGraphDataScience) -> Generator[No
2728 yield # Test runs here
2829
2930 # Runs after each test
31+ gds_with_cloud_setup .set_database ("neo4j" )
3032 gds_with_cloud_setup .run_cypher ("MATCH (n) DETACH DELETE n" )
3133
3234 res = gds_with_cloud_setup .graph .list ()
@@ -43,31 +45,45 @@ def test_remote_projection(gds_with_cloud_setup: AuraGraphDataScience) -> None:
4345 assert result ["nodeCount" ] == 3
4446
4547
46- @pytest .mark .cloud_architecture
48+ # @pytest.mark.cloud_architecture
4749@pytest .mark .compatible_with (min_inclusive = ServerVersion (2 , 7 , 0 ))
4850def test_remote_projection_and_writeback_custom_database_name (gds_with_cloud_setup : AuraGraphDataScience ) -> None :
4951 gds_with_cloud_setup .run_cypher ("CREATE DATABASE test1234 IF NOT EXISTS" )
5052 gds_with_cloud_setup .set_database ("test1234" )
51- gds_with_cloud_setup .run_cypher ("CREATE ()-[:T]->()" )
52- G , projection_result = gds_with_cloud_setup .graph .project (
53- GRAPH_NAME , "MATCH (n)-->(m) RETURN gds.graph.project.remote(n, m)"
54- )
5553
56- assert G .name () == GRAPH_NAME
57- assert projection_result ["nodeCount" ] == 2
58- assert projection_result ["relationshipCount" ] == 1
59-
60- write_result = gds_with_cloud_setup .wcc .write (G , writeProperty = "wcc" )
61-
62- assert write_result ["nodePropertiesWritten" ] == 2
63- count_wcc_nodes_query = "MATCH (n WHERE n.wcc IS NOT NULL) RETURN count(*) AS c"
64- nodes_with_wcc_custom_db = gds_with_cloud_setup .run_cypher (count_wcc_nodes_query ).squeeze ()
65- assert nodes_with_wcc_custom_db == 2
66- gds_with_cloud_setup .set_database ("neo4j" )
67- # we get a warning because property wcc doesn't exist in the database -- which is good!
68- with pytest .warns (RuntimeWarning ):
69- nodes_with_wcc_default_db = gds_with_cloud_setup .run_cypher (count_wcc_nodes_query ).squeeze ()
54+ try :
55+ gds_with_cloud_setup .run_cypher ("CREATE ()-[:T]->()" )
56+ G , projection_result = gds_with_cloud_setup .graph .project (
57+ GRAPH_NAME , "MATCH (n)-->(m) RETURN gds.graph.project.remote(n, m)"
58+ )
59+
60+ assert G .name () == GRAPH_NAME
61+ assert projection_result ["nodeCount" ] == 2
62+ assert projection_result ["relationshipCount" ] == 1
63+
64+ write_result = gds_with_cloud_setup .wcc .write (G , writeProperty = "wcc" )
65+
66+ assert write_result ["nodePropertiesWritten" ] == 2
67+ count_wcc_nodes_query = "MATCH (n WHERE n.wcc IS NOT NULL) RETURN count(*) AS c"
68+ nodes_with_wcc_custom_db = gds_with_cloud_setup .run_cypher (count_wcc_nodes_query ).squeeze ()
69+ assert nodes_with_wcc_custom_db == 2
70+ gds_with_cloud_setup .set_database ("neo4j" )
71+
72+ db_knows_wcc = gds_with_cloud_setup .run_cypher (
73+ "CALL db.propertyKeys() YIELD propertyKey WHERE propertyKey = 'wcc' RETURN count(*) > 0"
74+ ).squeeze ()
75+
76+ if db_knows_wcc :
77+ # this is the case if you have a dirty neo4j database with wcc set earlier
78+ nodes_with_wcc_default_db = gds_with_cloud_setup .run_cypher (count_wcc_nodes_query ).squeeze ()
79+ else :
80+ # we get a warning because property wcc doesn't exist in the database -- which is good!
81+ with pytest .warns (RuntimeWarning ):
82+ nodes_with_wcc_default_db = gds_with_cloud_setup .run_cypher (count_wcc_nodes_query ).squeeze ()
7083 assert nodes_with_wcc_default_db == 0
84+ finally :
85+ gds_with_cloud_setup .run_cypher ("DROP DATABASE test1234 IF EXISTS" )
86+ gds_with_cloud_setup .set_database ("neo4j" )
7187
7288
7389@pytest .mark .cloud_architecture
0 commit comments