MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _test_ops

Method _test_ops

test/test_comment.py:35–82  ·  view source on GitHub ↗
(
        self,
        helpers,
        already_supported,
        listener,
    )

Source from the content-addressed store, hash-verified

33
34class TestComment(IntegrationTest):
35 def _test_ops(
36 self,
37 helpers,
38 already_supported,
39 listener,
40 ):
41 for h, args in helpers:
42 c = "testing comment with " + h.__name__
43 with self.subTest("collection-" + h.__name__ + "-comment"):
44 for cc in [c, {"key": c}, ["any", 1]]:
45 listener.reset()
46 kwargs = {"comment": cc}
47 try:
48 maybe_cursor = h(*args, **kwargs)
49 except Exception:
50 maybe_cursor = None
51 self.assertIn(
52 "comment",
53 inspect.signature(h).parameters,
54 msg="Could not find 'comment' in the "
55 "signature of function %s" % (h.__name__),
56 )
57 self.assertEqual(
58 inspect.signature(h).parameters["comment"].annotation, "Optional[Any]"
59 )
60 if isinstance(maybe_cursor, CommandCursor):
61 maybe_cursor.close()
62
63 cmd = listener.started_events[0]
64 self.assertEqual(cc, cmd.command.get("comment"), msg=cmd)
65
66 if h.__name__ != "aggregate_raw_batches":
67 self.assertIn(
68 ":param comment:",
69 h.__doc__,
70 )
71 if h not in already_supported:
72 self.assertIn(
73 "Added ``comment`` parameter",
74 h.__doc__,
75 )
76 else:
77 self.assertNotIn(
78 "Added ``comment`` parameter",
79 h.__doc__,
80 )
81
82 listener.reset()
83
84 @client_context.require_version_min(4, 7, -1)
85 @client_context.require_replica_set

Callers 3

test_database_helpersMethod · 0.95
test_client_helpersMethod · 0.95

Calls 3

resetMethod · 0.45
closeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected