'Test basic worker update.'

def test_worker_update_no_subsecond(self):

    db.sqlalchemy.api.DB_SUPPORTS_SUBSECOND_RESOLUTION = False
    worker = self._create_workers(1)[0]
    worker = db.worker_get(self.ctxt, id=worker.id)
    now = datetime.utcnow().replace(microsecond=123)
    with mock.patch('oslo_utils.timeutils.utcnow', return_value=now):
        res = db.worker_update(self.ctxt, worker.id, service_id=1)
    self.assertEqual(1, res)
    worker.service_id = 1
    db_worker = db.worker_get(self.ctxt, id=worker.id)
    self._assertEqualObjects(worker, db_worker, ['updated_at', 'race_preventer'])
    self.assertEqual(0, db_worker.updated_at.microsecond)
    self.assertEqual((worker.race_preventer + 1), db_worker.race_preventer)
