(self)
| 499 | db.test.drop_indexes() |
| 500 | |
| 501 | def test_index_2dsphere(self): |
| 502 | db = self.db |
| 503 | db.test.drop_indexes() |
| 504 | self.assertEqual("geo_2dsphere", db.test.create_index([("geo", GEOSPHERE)])) |
| 505 | |
| 506 | for dummy, info in (db.test.index_information()).items(): |
| 507 | field, idx_type = info["key"][0] |
| 508 | if field == "geo" and idx_type == "2dsphere": |
| 509 | break |
| 510 | else: |
| 511 | self.fail("2dsphere index not found.") |
| 512 | |
| 513 | poly = {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [41, 5], [40, 5]]]} |
| 514 | query = {"geo": {"$within": {"$geometry": poly}}} |
| 515 | |
| 516 | # This query will error without a 2dsphere index. |
| 517 | db.test.find(query) |
| 518 | db.test.drop_indexes() |
| 519 | |
| 520 | def test_index_hashed(self): |
| 521 | db = self.db |
nothing calls this directly
no test coverage detected