Ejemplo n.º 1
0
def taskModify(request):
	try:
		tasks.update(request['id'],
			{
				'value':        request['value'],
				'target_user':  request['user'],
				'target_uuid':  request['uuid'],
				'target_descr': request['descr'],
			},
			request['time']
		)
	except Exception, e:
		LOG.error(e)
		return jsonrpc.result_error('ServerError',
			{ 'status': 'error', 'message': 'Unable to modify task' })
Ejemplo n.º 2
0
	def test_task_update(self):
		"""Check task recreating"""

		o = tasks.Task({
			"name":        str(uuid.uuid4()),
			"customer":    str(uuid.uuid4()),
			"rate_id":     str(uuid.uuid4()),
			"queue_id":    str(uuid.uuid4()),
			"time_create": int(time.time())-60
		})

		tasks.add(o)

		data = {'value': 29}
		ts = int(time.time() + 10)
		tasks.update(o.base_id, data, ts)
		with database.DBConnect(primarykey=o.base_id) as db:
			o1 = tasks.Task(db.find_one('tasks', {'base_id':o.base_id, 'record_id': '0' }))

		#Getting queues
		with database.DBConnect(primarykey=o.base_id) as db:
			nq = db.find_one('queue', {'id':o1.queue_id})
			oq = db.find_one('queue', {'id':o.queue_id})

		self.assertTrue(oq is not None)

		#Time_create is equal with time_check in new task
		self.assertEquals(o1.time_create, nq['time_check'])

		#New id's and time_create
		self.assertNotEquals(o1.queue_id, o.queue_id)
		self.assertNotEquals(o1.task_id, o.task_id)
		self.assertNotEquals(o1.time_create, o.time_create)

		#Updated data
		o.set(data)
		o1.queue_id = o.queue_id
		o1.task_id = o.task_id
		o1.time_create = o.time_create
		self.assertEquals(o1.values, o.values)