Skip to content

Commit

Permalink
quick test for creating an index on binary data - jeff wants to be su…
Browse files Browse the repository at this point in the history
…re this works
  • Loading branch information
Mike Dirolf committed Feb 17, 2009
1 parent fc08abc commit 7243426
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_collection.py
Expand Up @@ -21,6 +21,7 @@
import qcheck
from test_connection import get_connection
from pymongo.objectid import ObjectId
from pymongo.binary import Binary
from pymongo.collection import Collection
from pymongo.errors import InvalidName, OperationFailure
from pymongo import ASCENDING, DESCENDING
Expand Down Expand Up @@ -91,6 +92,18 @@ def test_create_index(self):
(u"key", SON([(u"hello", -1),
(u"world", 1)]))]))

def test_index_on_binary(self):
db = self.db
db.drop_collection("test")
db.test.save({"bin": Binary("def")})
db.test.save({"bin": Binary("abc")})
db.test.save({"bin": Binary("ghi")})

self.assertEqual(db.test.find({"bin": Binary("abc")}).explain()["nscanned"], 3)

db.test.create_index("bin", ASCENDING)
self.assertEqual(db.test.find({"bin": Binary("abc")}).explain()["nscanned"], 1)

def test_drop_index(self):
db = self.db
db.test.drop_indexes()
Expand Down

0 comments on commit 7243426

Please sign in to comment.