Skip to content

Commit

Permalink
MIM: failing test for positional dollar operator updating 2nd subitem
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Jun 18, 2020
1 parent a80a30b commit 256f2b1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ming/tests/test_mim.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,36 @@ def setUp(self):
'x': {} })
self.coll = self.bind.db.coll

def test_inc_dotted_dollar(self):
def test_inc_dotted_dollar_e1(self):
# match on e=1 and $inc
self.coll.update({'b.e': 1}, { '$inc': { 'b.e.$': 1 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.e': 1 })
self.assertEqual(obj, { 'b': { 'e': [ 2,2,3 ] } })

def test_inc_dotted_dollar_e2(self):
# match on e=2 and $inc
self.coll.update({'b.e': 2}, { '$inc': { 'b.e.$': 1 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.e': 1 })
self.assertEqual(obj, { 'b': { 'e': [ 1,3,3 ] } })

def test_inc_dotted_dollar_e3(self):
# match on e=3 and $inc
self.coll.update({'b.e': 3}, { '$inc': { 'b.e.$': 1 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.e': 1 })
self.assertEqual(obj, { 'b': { 'e': [ 1,2,4 ] } })

def test_inc_dotted_dollar_middle1(self):
# match on g=1 and $inc by 10
self.coll.update({'b.f.g': 1}, { '$inc': { 'b.f.$.g': 10 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.f': 1 })
self.assertEqual(obj, { 'b': { 'f': [ { 'g': 11 }, { 'g': 2 } ] }})

def test_inc_dotted_dollar_middle2(self):
# match on g=2 and $inc by 10
self.coll.update({'b.f.g': 2}, { '$inc': { 'b.f.$.g': 10 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.f': 1 })
self.assertEqual(obj, { 'b': { 'f': [ { 'g': 1 }, { 'g': 12 } ] }})

def test_find_dotted(self):
self.assertEqual(self.coll.find({'b.c': 1}).count(), 1)
self.assertEqual(self.coll.find({'b.c': 2}).count(), 0)
Expand Down

0 comments on commit 256f2b1

Please sign in to comment.