-
Notifications
You must be signed in to change notification settings - Fork 199
Python Aura Example #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python Aura Example #431
Conversation
|
||
# python -m pytest tests/integration/examples/test_hello_world_example.py -s -v | ||
|
||
# tag::aura[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the tag, I can introduce the tag when this example is used in the next version of the python driver manual. The tags are used to get code snippets to the driver manual, they need to be unique named.
app.close() | ||
|
||
|
||
# end::aura[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
# end::aura[]
# tag::hello-world-output[]
# hello, world, from node 1234
# end::hello-world-output[]
# end::hello-world-output[] | ||
|
||
|
||
def test_hello_world_example(uri, auth): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change name to be test_aura_example
s = StringIO() | ||
with redirect_stdout(s): | ||
example = App(uri, auth[0], auth[1]) | ||
example.create_friendship("hello, world") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the test parameters to be some other names like "Alice", "Bob"
example.create_friendship("hello, world") | ||
example.close() | ||
|
||
assert s.getvalue().startswith("hello, world, from node ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the find_person
function to test the example.
with self.driver.session() as session: | ||
result = session.read_transaction(self._find_and_return_person, person_name) | ||
for row in result: | ||
print(f"Found person: {row}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont use f
string function, the test suit will fail for python 3.5
use: print("Found person: {row}".format(row=row))
result = session.write_transaction(self._create_and_return_friendship, | ||
person1_name, person2_name) | ||
for row in result: | ||
print(f"Created friendship between: {row['p1']}, {row['p2']}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont use the f
string, it will fail for python 3.5
@martin-neotech have applied all those changes hopefully. We want to use the tags in Aura land as well, so I'll check back on what the actual tag name should be. Below is a test of the asciidoc code that I'm using to test how it'll look in Aura land when we pull in this example:
We'll update that to use the neo4j repository rather than my one before it's actually published. |
for row in result] | ||
# Capture any errors along with the query and data for traceability | ||
except ServiceUnavailable as exception: | ||
logging.error(f"{query} raised an error: \n {exception}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f
string, syntax error for python 3.5 when testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martin-neotech have applied all those changes hopefully.
We want to use the tags in Aura land as well, so I'll check back on what the actual tag name should be. Below is a test of the asciidoc code that I'm using to test how it'll look in Aura land when we pull in this example:[source,python] ---- include::https://raw.githubusercontent.com/mneedham/neo4j-python-driver/aura/tests/integration/examples/test_aura_example.py[tag="aura-import"] include::https://raw.githubusercontent.com/mneedham/neo4j-python-driver/aura/tests/integration/examples/test_aura_example.py[tag="aura"] ----
We'll update that to use the neo4j repository rather than my one before it's actually published.
Ok, the naming should maybe be something more generic then like
test_driver_introduction_example.py
and the tag"driver-introduction-example"
?
Yeh that sounds good. I'll update the test name to reflect that
Ok, the naming should maybe be something more generic then like |
* Python Aura Example (#431) * aura example * aura example * add placeholders * update link * addressing martin's feedback * remove another tag * remove f string * rename to be more generic * add tags * initiated the 4.1 bolt protocol Co-authored-by: Mark Needham <m.h.needham@gmail.com>
* Python Aura Example (#431) * aura example * aura example * add placeholders * update link * addressing martin's feedback * remove another tag * remove f string * rename to be more generic * add tags * reintroduced helper functions for the Record object and updated documentation * updated docs that it is a values lists e.g. [[1,0], [2,0], [3,0]] Co-authored-by: Mark Needham <m.h.needham@gmail.com>
No description provided.