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

Method test_repr

test/test_operations.py:38–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

36 """Test IndexModel features."""
37
38 def test_repr(self):
39 # Based on examples in test_collection.py
40 self.assertRepr(IndexModel("hello"))
41 self.assertRepr(IndexModel([("hello", DESCENDING), ("world", ASCENDING)]))
42 self.assertRepr(
43 IndexModel([("hello", DESCENDING), ("world", ASCENDING)], name="hello_world")
44 )
45 # Test all the kwargs
46 self.assertRepr(IndexModel("name", name="name"))
47 self.assertRepr(IndexModel("unique", unique=False))
48 self.assertRepr(IndexModel("background", background=True))
49 self.assertRepr(IndexModel("sparse", sparse=True))
50 self.assertRepr(IndexModel("bucketSize", bucketSize=1))
51 self.assertRepr(IndexModel("min", min=1))
52 self.assertRepr(IndexModel("max", max=1))
53 self.assertRepr(IndexModel("expireAfterSeconds", expireAfterSeconds=1))
54 self.assertRepr(
55 IndexModel("partialFilterExpression", partialFilterExpression={"hello": "world"})
56 )
57 self.assertRepr(IndexModel("collation", collation=Collation(locale="en_US")))
58 self.assertRepr(IndexModel("wildcardProjection", wildcardProjection={"$**": 1}))
59 self.assertRepr(IndexModel("hidden", hidden=False))
60 # Test string literal
61 self.assertEqual(repr(IndexModel("hello")), "IndexModel({'hello': 1}, name='hello_1')")
62 self.assertEqual(
63 repr(IndexModel({"hello": 1, "world": -1})),
64 "IndexModel({'hello': 1, 'world': -1}, name='hello_1_world_-1')",
65 )
66
67
68class TestSearchIndexModel(TestOperationsBase):

Callers

nothing calls this directly

Calls 3

IndexModelClass · 0.90
CollationClass · 0.90
assertReprMethod · 0.45

Tested by

no test coverage detected