Example #1
0
	def test_customer_deposit(self):
		"""Check wallet incrimention"""

		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)

		value = 2**random.randint(3, 10)
		customers.deposit(cus.id, value)

		cus.set({'wallet': cus.wallet+value})

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

		self.assertEquals(customers.Customer(c1), cus)
Example #2
0
def customerDeposit(params):
	""" Make deposit to customer """

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

		if params['value'] != 0:
			customers.deposit(params['id'], params['value'])

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