Beispiel #1
0
	def test_tariff_delete(self):
		"""Check state changing"""

		data = {
			'id':           unicode(uuid.uuid4()),
			'name':         str(uuid.uuid4()),
			'description':  str(uuid.uuid4()),
			'state':        tariffs.constants.STATE_ENABLED,
			'time_create':  int(time.time()),
			'time_destroy': 0,
		}

		tar = tariffs.Tariff(data)

		with database.DBConnect() as db:
			db.insert('tariffs', data)

		tariffs.remove('id', tar.id)
		tar.set({'state': tariffs.constants.STATE_DELETED,
			'time_destroy': int(time.time())})

		with self.assertRaises(ValueError):
			tariffs.remove('state', tar.id)

		with database.DBConnect() as db:
			t1 = db.find_one('tariffs', {'id': tar.id})

		self.assertEquals(tariffs.Tariff(t1), tar)
Beispiel #2
0
def tariffRemove(params):
	try:
		srv = zones.write_zone(params['id'])
		if not srv['local']:
			return jsonrpc.result({ 'status':'redirect', 'server': srv['server'] })

		tariffs.remove('id', params['id'])

	except Exception, e:
		LOG.error(e)
		return jsonrpc.result_error('ServerError',
			{ 'status': 'error', 'message': 'Unable to remove tariff' })