I'm going through the python tutorial and when I get to the lesson Browsing Genre, and run the test, I get the following error messsage:
============================================================ test session starts ============================================================
platform linux -- Python 3.11.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /workspace/app-python
collected 1 item
tests/09_genre_list__test.py F
================================================================= FAILURES ==================================================================
________________________________________________________ test_return_list_of_genres _________________________________________________________
app = <Flask 'api'>
def test_return_list_of_genres(app):
with app.app_context():
# Get Neo4j Driver
driver = get_driver()
# Create DAO
dao = GenreDAO(driver)
# Get all genres
> output = dao.all()
tests/09_genre_list__test.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
api/dao/genres.py:53: in all
return session.execute_read(get_movies)
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/session.py:660: in execute_read
return self._run_transaction(
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/session.py:551: in _run_transaction
result = transaction_function(tx, *args, **kwargs)
api/dao/genres.py:30: in get_movies
result = tx.run("""
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/transaction.py:169: in run
result._tx_ready_run(query, parameters)
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/result.py:131: in _tx_ready_run
self._run(query, parameters, None, None, None, None, None, None)
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/result.py:181: in _run
self._attach()
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/work/result.py:298: in _attach
self._connection.fetch_message()
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/io/_common.py:178: in inner
func(*args, **kwargs)
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/io/_bolt.py:849: in fetch_message
res = self._process_message(tag, fields)
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/io/_bolt5.py:374: in _process_message
response.on_failure(summary_metadata or {})
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <neo4j._sync.io._common.Response object at 0x7fbdd2f69750>
metadata = {'code': 'Neo.ClientError.Statement.SyntaxError', 'message': 'A pattern expression should only be used in order to tes...4 (offset
: 468))\n" movies: size((g)<-[:IN_GENRE]-(:Movie)),"\n ^'}
def on_failure(self, metadata):
""" Called when a FAILURE message has been received.
"""
try:
self.connection.reset()
except (SessionExpired, ServiceUnavailable):
pass
handler = self.handlers.get("on_failure")
Util.callback(handler, metadata)
handler = self.handlers.get("on_summary")
Util.callback(handler)
> raise Neo4jError.hydrate(**metadata)
E neo4j.exceptions.CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: A pattern expression should only be used
in order to test the existence of a pattern. It can no longer be used inside the function size(), an alternative is to replace size() with COUNT {}. (line 13, column 34 (offset: 468)) E " movies: size((g)<-[:IN_GENRE]-(:Movie)),"
E ^}
../.pyenv_mirror/user/3.11.6/lib/python3.11/site-packages/neo4j/_sync/io/_common.py:245: CypherSyntaxError
========================================================== short test summary info ==========================================================
FAILED tests/09_genre_list__test.py::test_return_list_of_genres - neo4j.exceptions.CypherSyntaxError: {code: Neo.ClientError.Statement.Syn...
============================================================= 1 failed in 0.55s =============================================================
The issue persists even if I use the answer I constructed during the lesson, copy and paste the answer provided at the end of lesson, as well as if I copy the contents of the file in the api/dao/genres.py, so I don't know exactly how to solve the problem in the Cypher syntax.
Also for some reason, whenever I use
export FLASK_APP=api
export FLASK_ENV=development
flask run
To run the aplication from the GitPod instance, the application appears with no data and with none of the functionalities implemented thus far, even though it passed all the tests before this one. So I don't know what is wrong when I run the aplication from GitPod.
I hope anyone can help me with this.
Regards,
Nicholas
I'm going through the python tutorial and when I get to the lesson Browsing Genre, and run the test, I get the following error messsage:
The issue persists even if I use the answer I constructed during the lesson, copy and paste the answer provided at the end of lesson, as well as if I copy the contents of the file in the api/dao/genres.py, so I don't know exactly how to solve the problem in the Cypher syntax.
Also for some reason, whenever I use
To run the aplication from the GitPod instance, the application appears with no data and with none of the functionalities implemented thus far, even though it passed all the tests before this one. So I don't know what is wrong when I run the aplication from GitPod.
I hope anyone can help me with this. Regards, Nicholas