def test_add_string_complete(self):
        query_builder = QueryBuilder().add_custom_cypher("MATCH (n) RETURN n")
        expected_query = "MATCH (n) RETURN n"

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_limit(self):
        query_builder = QueryBuilder().match().node(variable="n").limit("3")
        expected_query = " MATCH (n) LIMIT 3 "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_simple_merge(self):
        query_builder = QueryBuilder().merge().node(
            "L1", variable="n").to("TO").node("L2").return_()
        expected_query = " MERGE (n:L1)-[:TO]->(:L2) RETURN * "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_orderby_desc(self):
        query_builder = QueryBuilder().match().node(
            variable="n").order_by("n.id DESC")
        expected_query = " MATCH (n) ORDER BY n.id DESC "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_remove_label(self):
        query_builder = QueryBuilder().match().node(
            variable="n", labels=["Node1", "Node2"]).remove({"n:Node2"})
        expected_query = " MATCH (n:Node1:Node2) REMOVE n:Node2 "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_with(self):
        query_builder = QueryBuilder().match().node(variable="n").with_(
            {"n": ""})
        expected_query = " MATCH (n) WITH n "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_with_empty(self):
        query_builder = QueryBuilder().match().node(
            "L1", variable="n").to("TO").node("L2", variable="m").with_()
        expected_query = " MATCH (n:L1)-[:TO]->(m:L2) WITH * "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_call_procedure_node2vec(self):
        query_builder = QueryBuilder().call(
            procedure="node2vec_online.get_embeddings",
            arguments="False, 2.0, 0.5")
        expected_query = " CALL node2vec_online.get_embeddings(False, 2.0, 0.5) "
        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)
    def test_delete(self):
        query_builder = QueryBuilder().match().node(variable="n1",
                                                    labels="Node1").delete(
                                                        {"n1"})
        expected_query = " MATCH (n1:Node1) DELETE n1 "

        with patch.object(Memgraph, "execute_and_fetch",
                          return_value=None) as mock:
            query_builder.execute()

        mock.assert_called_with(expected_query)