def _TestUpdateDevice(tester, user_cookie, request_dict):
 validator = tester.validator
 (user_id, device_id) = tester.GetIdsFromCookie(user_cookie)
 request_dict = deepcopy(request_dict)
 device_dict = request_dict['device_dict']
 actual_dict = tester.SendRequest('update_device', user_cookie, request_dict)
 device_dict['user_id'] = user_id
 if ('push_token' in device_dict):
  device_dict['alert_user_id'] = user_id
 device_dict.pop('device_uuid', None)
 device_dict.pop('test_udid', None)
 device = validator.ValidateUpdateDBObject(Device, last_access=util._TEST_TIME, **device_dict)
 if ('push_token' in device_dict):
  predicate = (lambda d: ((d.push_token == device_dict['push_token']) and (d.device_id != device_dict['device_id'])))
  for other_device in validator.QueryModelObjects(Device, predicate=predicate):
   validator.ValidateUpdateDBObject(Device, user_id=other_device.user_id, device_id=other_device.device_id, push_token=None, alert_user_id=None)
 tester._CompareResponseDicts('update_device', user_id, request_dict, {}, actual_dict)
 return actual_dict

def _TestUpdateDevice ( tester , user_cookie , request_dict ) : validator = tester . validator ( user_id , device_id ) = tester . GetIdsFromCookie ( user_cookie ) request_dict = deepcopy ( request_dict ) device_dict = request_dict [ 'device_dict' ] actual_dict = tester . SendRequest ( 'update_device' , user_cookie , request_dict ) device_dict [ 'user_id' ] = user_id if ( 'push_token' in device_dict ) : device_dict [ 'alert_user_id' ] = user_id device_dict . pop ( 'device_uuid' , None ) device_dict . pop ( 'test_udid' , None ) device = validator . ValidateUpdateDBObject ( Device , last_access = util . _TEST_TIME , ** device_dict ) if ( 'push_token' in device_dict ) : predicate = ( lambda d : ( ( d . push_token == device_dict [ 'push_token' ] ) and ( d . device_id != device_dict [ 'device_id' ] ) ) ) for other_device in validator . QueryModelObjects ( Device , predicate = predicate ) : validator . ValidateUpdateDBObject ( Device , user_id = other_device . user_id , device_id = other_device . device_id , push_token = None , alert_user_id = None ) tester . _CompareResponseDicts ( 'update_device' , user_id , request_dict , { } , actual_dict ) return actual_dict
called by the servicetester in order to test update_device service api call .