Skip to content

PYTHON-3527 + PYTHON-3528 Fix no-server tests #1118

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 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 19 additions & 10 deletions test/test_create_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import unittest

sys.path[0:0] = [""]

from test import IntegrationTest
from test.unified_format import UnifiedSpecTestMixinV1


class TestCreateEntities(unittest.TestCase):
class TestCreateEntities(IntegrationTest):
def test_store_events_as_entities(self):
self.scenario_runner = UnifiedSpecTestMixinV1()
spec = {
Expand Down Expand Up @@ -91,7 +96,7 @@ def test_store_all_others_as_entities(self):
{
"name": "insertOne",
"object": "collection0",
"arguments": {"document": {"_id": 1, "x": 44}},
"arguments": {"document": {"_id": 2, "x": 44}},
},
],
},
Expand All @@ -101,15 +106,19 @@ def test_store_all_others_as_entities(self):
],
}

self.client.dat.dat.delete_many({})
self.scenario_runner.TEST_SPEC = spec
self.scenario_runner.setUp()
self.scenario_runner.run_scenario(spec["tests"][0])
self.scenario_runner.entity_map["client0"].close()
final_entity_map = self.scenario_runner.entity_map
for entity in ["errors", "failures"]:
self.assertIn(entity, final_entity_map)
self.assertGreaterEqual(len(final_entity_map[entity]), 0)
self.assertEqual(type(final_entity_map[entity]), list)
for entity in ["successes", "iterations"]:
self.assertIn(entity, final_entity_map)
self.assertEqual(type(final_entity_map[entity]), int)
entity_map = self.scenario_runner.entity_map
self.assertEqual(len(entity_map["errors"]), 4)
for error in entity_map["errors"]:
self.assertEqual(error["type"], "DuplicateKeyError")
self.assertEqual(entity_map["failures"], [])
self.assertEqual(entity_map["successes"], 2)
self.assertEqual(entity_map["iterations"], 5)


if __name__ == "__main__":
unittest.main()
6 changes: 5 additions & 1 deletion test/test_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Test that each file in mypy_fails/ actually fails mypy, and test some
sample client code that uses PyMongo typings."""
import os
import sys
import tempfile
import unittest
from typing import TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Union
Expand Down Expand Up @@ -51,7 +52,9 @@ class ImplicitMovie(TypedDict):
except ImportError:
api = None # type: ignore[assignment]

from test import IntegrationTest
sys.path[0:0] = [""]

from test import IntegrationTest, client_context
from test.utils import rs_or_single_client

from bson import CodecOptions, decode, decode_all, decode_file_iter, decode_iter, encode
Expand Down Expand Up @@ -430,6 +433,7 @@ def test_typeddict_empty_document_type(self) -> None:
# This should fail because _id is not included in our TypedDict definition.
assert out["_id"] # type:ignore[typeddict-item]

@client_context.require_connection
def test_typeddict_find_notrequired(self):
if NotRequired is None or ImplicitMovie is None:
raise unittest.SkipTest("Python 3.11+ is required to use NotRequired.")
Expand Down