Skip to content

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

Merged
merged 9 commits into from
Jun 30, 2020
Merged

Python Aura Example #431

merged 9 commits into from
Jun 30, 2020

Conversation

mneedham
Copy link
Contributor

No description provided.


# python -m pytest tests/integration/examples/test_hello_world_example.py -s -v

# tag::aura[]
Copy link
Contributor

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[]
Copy link
Contributor

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):
Copy link
Contributor

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")
Copy link
Contributor

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 ")
Copy link
Contributor

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}")
Copy link
Contributor

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']}")
Copy link
Contributor

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

@mneedham
Copy link
Contributor Author

@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.

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}")
Copy link
Contributor

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

Copy link
Contributor Author

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

@martin-neotech
Copy link
Contributor

@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" ?

@martin-neotech martin-neotech merged commit e881867 into neo4j:4.0 Jun 30, 2020
martin-neotech added a commit that referenced this pull request Jun 30, 2020
* 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

Co-authored-by: Mark Needham <m.h.needham@gmail.com>
martin-neotech added a commit that referenced this pull request Jun 30, 2020
* 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>
martin-neotech added a commit that referenced this pull request Jul 1, 2020
* 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

Co-authored-by: Mark Needham <m.h.needham@gmail.com>
martin-neotech added a commit that referenced this pull request Jul 3, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants