def test_compare_not_update(self):
     resource1 = self._create()
     values = {'processing': not resource1['processing']}
     filters = {'allocated': not resource1['allocated']}
     resource2 = db.resource_compare_update(resource1['id'], filters,
                                            values)
     self.assertIsNone(resource2)
 def test_compare_update_updates_right_resource(self):
     self._create()
     resource2 = self._create()
     self._create()
     values = {'status': 'ERROR'}
     filters = {'allocated': resource2['allocated']}
     retval = db.resource_compare_update(resource2['id'], filters, values)
     self.assertIsNotNone(retval)
     resource2 = db.resource_get_by_id(resource2['id'])
     self.assertEqual('ERROR', resource2['status'])
 def test_compare_update(self):
     resource1 = self._create()
     values = {'processing': not resource1['processing']}
     resource2 = db.resource_compare_update(resource1['id'], {}, values)
     resource1.update(values)
     self.assertDictEqual(resource1, resource2)