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

		data = {
			'id': str(uuid.uuid4()),
			'login': str(uuid.uuid4()),
			'name_short': str(uuid.uuid4()),
			'name_full': str(uuid.uuid4()),
			'comment': str(uuid.uuid4()),
			'contract_client': str(uuid.uuid4()),
			'contract_service': str(uuid.uuid4()),
			'tariff_id': str(uuid.uuid4()),
			'contact_person': str(uuid.uuid4()),
			'contact_email': str(uuid.uuid4()),
			'contact_phone': str(uuid.uuid4())[:10],
			'state': customers.constants.STATE_ENABLED,
			'time_create': int(time.time()),
			'time_destroy': 0,
			'wallet': 10,
			'wallet_mode': customers.constants.WALLET_MODE_LIMITED
			}
		cus = customers.Customer(data)

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

		cus.set({'state': customers.constants.STATE_DELETED,
			'time_destroy': int(time.time())})

		with self.assertRaises(ValueError):
			customers.remove(random.choice(list(set(data.keys())-set(['login', 'id']))), cus.id)

		customers.remove('id', cus.id)

		with database.DBConnect() as db:
			c1 = db.find_one('customers', {'id': cus.id})

		self.assertEquals(customers.Customer(c1), cus)
Beispiel #2
0
def customerRemove(params):
	""" Remove customer by name """

	try:
		srv = zones.write_zone(params['id'])
		if not srv['local']:
			return jsonrpc.result({ 'status':'redirect', 'server': srv['server'] })

		c = customers.remove('id', params['id'])

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