Skip to content

Commit

Permalink
Re-add tests for the _get_query_tail function (deleted by mistake)
Browse files Browse the repository at this point in the history
  • Loading branch information
stellasia committed May 7, 2024
1 parent a6cf577 commit 25688fe
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/unit/test_neo4j_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from neo4j_genai.neo4j_queries import get_search_query
from neo4j_genai.neo4j_queries import get_search_query, _get_query_tail
from neo4j_genai.types import SearchType


Expand Down Expand Up @@ -106,3 +106,50 @@ def test_hybrid_search_with_properties():
)
result, _ = get_search_query(SearchType.HYBRID, return_properties=properties)
assert result.strip() == expected.strip()


def test_get_query_tail_with_retrieval_query():
retrieval_query = "MATCH (n) RETURN n LIMIT 10"
expected = retrieval_query
result = _get_query_tail(retrieval_query=retrieval_query)
assert result.strip() == expected.strip()


def test_get_query_tail_with_properties():
properties = ["name", "age"]
expected = "RETURN node {.name, .age} as node, score"
result = _get_query_tail(return_properties=properties)
assert result.strip() == expected.strip()


def test_get_query_tail_with_fallback():
fallback = "HELLO"
expected = fallback
result = _get_query_tail(fallback_return=fallback)
assert result.strip() == expected.strip()


def test_get_query_tail_ordering_all():
retrieval_query = "MATCH (n) RETURN n LIMIT 10"
properties = ["name", "age"]
fallback = "HELLO"

expected = retrieval_query
result = _get_query_tail(
retrieval_query=retrieval_query,
return_properties=properties,
fallback_return=fallback,
)
assert result.strip() == expected.strip()


def test_get_query_tail_ordering_no_retrieval_query():
properties = ["name", "age"]
fallback = "HELLO"

expected = "RETURN node {.name, .age} as node, score"
result = _get_query_tail(
return_properties=properties,
fallback_return=fallback,
)
assert result.strip() == expected.strip()

0 comments on commit 25688fe

Please sign in to comment.