Пример #1
0
  def testAddModeIdAndSpecTwice(self):
    inSpec = {"$and": [{'type': 'move'}, {'commute':'on'}]}
    expectedSpec = {"$and": [{'type': 'move'}, {'commute':'on'}, {'confirmed_mode': 4}]}
    firstSpec = common.addModeIdToSpec(inSpec, 3)

    retSpec = common.addModeIdToSpec(inSpec, 4)
    logging.debug(retSpec)
    self.assertIn({'type': 'move'}, retSpec['$and'])
    self.assertIn({'commute': 'on'}, retSpec['$and'])
    self.assertIn({'corrected_mode': 4}, retSpec['$and'][2]['$or'])
    self.assertIn({'confirmed_mode': 4}, retSpec['$and'][2]['$or'][1]['$and'])
    self.assertIn({'test_auto_confirmed.mode': 4}, retSpec['$and'][2]['$or'][2]['$and'][2]['$or'])
Пример #2
0
 def testAddModeIdNone(self):
   inSpec = None
   retSpec = common.addModeIdToSpec(inSpec, 3)
   self.assertEquals(retSpec['$or'][0], {'corrected_mode': 3})
   self.assertEquals(retSpec['$or'][1]['$and'][0], {'corrected_mode': {'$exists': False}})
   self.assertEquals(retSpec['$or'][2]['$and'][0], {'corrected_mode': {'$exists': False}})
   self.assertEquals(retSpec['$or'][2]['$and'][1], {'confirmed_mode': {'$exists': False}})
   self.assertIn({'test_auto_confirmed.mode': 3}, retSpec['$or'][2]['$and'][2]['$or'])
Пример #3
0
 def testAddModeIdNonAndSpec(self):
   inSpec = {'type': 'move'}
   retSpec = common.addModeIdToSpec(inSpec, 3)
   self.assertEqual(retSpec["$and"][0], {"type" : "move"})
   self.assertIn("$or", retSpec['$and'][1])
   self.assertEqual(retSpec['$and'][1]["$or"][0], {"corrected_mode": 3})
   self.assertEqual(retSpec['$and'][1]["$or"][1]['$and'][1], {"confirmed_mode": 3})
   self.assertIn({'test_auto_confirmed.mode': 3}, retSpec['$and'][1]["$or"][2]['$and'][2]["$or"])
Пример #4
0
 def testAddModeIdAndSpec(self):
   inSpec = {"$and": [{'type': 'move'}, {'commute':'on'}]}
   retSpec = common.addModeIdToSpec(inSpec, 3)
   logging
   self.assertIn({'type': 'move'}, retSpec['$and'])
   self.assertIn({'commute': 'on'}, retSpec['$and'])
   self.assertIn({'corrected_mode': 3}, retSpec['$and'][2]['$or'])
   self.assertIn({'confirmed_mode': 3}, retSpec['$and'][2]['$or'][1]['$and'])
   self.assertIn({'test_auto_confirmed.mode': 3}, retSpec['$and'][2]['$or'][2]['$and'][2]['$or'])