Skip to content

PYTHON-3131 Test Failure - test_mypy on macos + auth #875

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 4 commits into from
Feb 17, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion test/test_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
except ImportError:
api = None

from test import client_context
from test.utils import rs_or_single_client

from bson.son import SON
from pymongo.collection import Collection
from pymongo.errors import ServerSelectionTimeoutError
Expand Down Expand Up @@ -58,8 +61,9 @@ class TestPymongo(unittest.TestCase):
coll: Collection

@classmethod
@client_context.require_connection
def setUpClass(cls) -> None:
cls.client = MongoClient(serverSelectionTimeoutMS=250, directConnection=False)
cls.client = rs_or_single_client(serverSelectionTimeoutMS=250, directConnection=False)
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this class inherit from IntegrationTest, then we get a self.client and client_context.require_connection for free.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

cls.coll = cls.client.test.test
try:
cls.client.admin.command("ping")
Expand All @@ -70,6 +74,7 @@ def setUpClass(cls) -> None:
def tearDownClass(cls) -> None:
cls.client.close()

@client_context.require_no_auth
def test_insert_find(self) -> None:
doc = {"my": "doc"}
coll2 = self.client.test.test2
Expand All @@ -82,6 +87,7 @@ def test_insert_find(self) -> None:
result2 = coll2.insert_one(retreived)
self.assertEqual(result2.inserted_id, result.inserted_id)

@client_context.require_no_auth
def test_cursor_iterable(self) -> None:
def to_list(iterable: Iterable[Dict[str, Any]]) -> List[Dict[str, Any]]:
return list(iterable)
Expand All @@ -91,12 +97,14 @@ def to_list(iterable: Iterable[Dict[str, Any]]) -> List[Dict[str, Any]]:
docs = to_list(cursor)
self.assertTrue(docs)

@client_context.require_no_auth
def test_bulk_write(self) -> None:
self.coll.insert_one({})
requests = [InsertOne({})]
result = self.coll.bulk_write(requests)
self.assertTrue(result.acknowledged)

@client_context.require_no_auth
def test_aggregate_pipeline(self) -> None:
coll3 = self.client.test.test3
coll3.insert_many(
Expand Down