Skip to content

PYTHON-4804 Migrate test_comment.py to async #1887

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 17 commits into from
Oct 11, 2024

Conversation

sleepyStick
Copy link
Contributor

No description provided.

@sleepyStick sleepyStick changed the title Migrate test_comment.py to async PYTHON-4804 Migrate test_comment.py to async Oct 1, 2024
@sleepyStick
Copy link
Contributor Author

sleepyStick commented Oct 1, 2024

Not sure why the link check is failing...I don't think its anything I did?

@sleepyStick sleepyStick marked this pull request as ready for review October 1, 2024 19:26
@sleepyStick sleepyStick requested a review from NoahStapp October 1, 2024 19:26
@blink1073
Copy link
Member

Not sure why the link check is failing...I don't think its anything I did?

No, the docs team is working on a fix

listener.reset()
kwargs = {"comment": cc}
if h == coll.rename:
_ = await db.get_collection("temp_temp_temp").drop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this underscore needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not! just removed it :)

Comment on lines 71 to 74
if iscoroutinefunction(coll.create_index):
await coll.create_index("a")
else:
coll.create_index("a")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if iscoroutinefunction(coll.create_index):
await coll.create_index("a")
else:
coll.create_index("a")
if not _IS_SYNC and isinstance(coll, Empty):
coll.create_index("a")
else:
await coll.create_index("a")

For clarity so unfamiliar readers can understand why coll.create_index could be synchronous.

Comment on lines 75 to 78
if iscoroutinefunction(h):
maybe_cursor = await h(*args, **kwargs)
else:
maybe_cursor = h(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if iscoroutinefunction(h):
maybe_cursor = await h(*args, **kwargs)
else:
maybe_cursor = h(*args, **kwargs)
if not _IS_SYNC and iscoroutinefunction(h):
maybe_cursor = await h(*args, **kwargs)
else:
maybe_cursor = h(*args, **kwargs)

Same here.

NoahStapp
NoahStapp previously approved these changes Oct 8, 2024
Copy link
Contributor

@NoahStapp NoahStapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sleepyStick
Copy link
Contributor Author

Oops, didn't realize that merging would dismiss the review...sorry!

from test import IntegrationTest, client_context, unittest
from test.utils import EventListener

from bson.dbref import DBRef
from pymongo.operations import IndexModel
from pymongo.synchronous.command_cursor import CommandCursor

_IS_SYNC = True


class Empty:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Empty class looks very suspicious. What's the point of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhhh honestly not sure. It was added in PYTHON-2682.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaned up _test_ops and now Empty isn't needed anymore :)

coll.create_index("a")
maybe_cursor = h(*args, **kwargs)
if not _IS_SYNC and isinstance(coll, Empty):
coll.create_index("a")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we call create_index when coll is Empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a great question...HAHA code is removed now.

ShaneHarvey
ShaneHarvey previously approved these changes Oct 10, 2024
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the tests pass.

@sleepyStick sleepyStick merged commit 33163ec into mongodb:master Oct 11, 2024
36 checks passed
@sleepyStick sleepyStick deleted the PYTHON-4804 branch October 11, 2024 23:02
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.

4 participants