Exemplo n.º 1
0
	def test_rate_add(self):
		"""Check the creating rate with rateAdd"""

		data={
				'id':           str(uuid.uuid4()),
				'description':  str(uuid.uuid4()),
				'metric_id':    str(uuid.uuid4()),
				'tariff_id':    str(uuid.uuid4()),
				'rate':         long(random.randint(10**3, 10**10)),
				'currency':     'RUB',
				'state':        'ACTIVE',
				'time_create':  int(time.time()),
				'time_destroy': 0,
				'sync':         0,
		}
		
		tariffs.add(tariffs.Tariff({'id':data['tariff_id']}))

		metrics.add(metrics.Metric({'id':data['metric_id']}))

		self.assertEquals(wapi_rates.rateAdd(data.copy()), requestor({'id':data['id']}, 'ok'))

		data['currency'] = rates.constants.CURRENCY_RUB
		data['state'] = rates.constants.STATE_ACTIVE
		with database.DBConnect() as db:
			t1 = db.find('rates').one()
		self.assertEquals(hashable_dict(data), hashable_dict(t1))

		with mocker([('bc.rates.add', mocker.exception),
					('bc_wapi.wapi_rates.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_rates.rateAdd({'id':''}),
				requestor({'message': 'Unable to add new rate' }, 'servererror'))
Exemplo n.º 2
0
	def test_tariff_remove(self):
		"""Check state changing with tariffRemove"""

		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,
			'sync':         0,
		}

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

		wapi_tariffs.tariffRemove({'id':data['id']})

		data['state'] = tariffs.constants.STATE_DELETED
		data['time_destroy'] = int(time.time())

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

		self.assertEquals(t1, data)

		with mocker([('bc.tariffs.remove', mocker.exception),
					('bc_wapi.wapi_tariffs.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_tariffs.tariffRemove({'id':''}),
				requestor({'message': 'Unable to remove tariff' }, 'servererror'))
Exemplo n.º 3
0
	def test_metric_get_list(self):
		"""Check getting metrics with metricList"""

		data = []
		for i in range(2, 10):
			d={
				'id':         str(uuid.uuid4()),
				'type':       str(uuid.uuid4())[:10],
				'formula':    metrics.constants.FORMULA_SPEED,
				'aggregate':  0L,
			}

			with database.DBConnect() as db:
				db.insert('metrics', d)

			data.append(d)

		ans = wapi_metrics.metricList('')
		self.assertEquals(ans[0], (01 << 2))
		self.assertEquals(ans[1]['status'], 'ok')

		self.assertEquals(set(map(lambda x: hashable_dict(x), ans[1]['metrics'])),
				set(map(lambda x: hashable_dict(x), data)))

		with mocker([('bc.metrics.get_all', mocker.exception),
					('bc_wapi.wapi_metrics.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_metrics.metricList({'id':''}),
				requestor({'message': 'Unable to obtain metric list' }, 'servererror'))
Exemplo n.º 4
0
	def test_customers_get(self):
		"""Check getting customer with customerGet"""

		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
		}

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

		self.assertEquals(wapi_customers.customerGet({'id': data['id']}),
				requestor({'customer': data}, 'ok'))

		self.assertEquals(wapi_customers.customerGet({'id':''}),
				requestor({'message': 'Customer not found' }, 'error'))

		with mocker([('bc.customers.get', mocker.exception),
					('bc_wapi.wapi_customers.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_customers.customerGet({'id':''}),
				requestor({'message': 'Unable to obtain customer' }, 'servererror'))
Exemplo n.º 5
0
	def test_tariff_get(self):
		"""Check getting tariff with tariffGet"""

		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,
		}

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

		self.assertEquals(wapi_tariffs.tariffGet({'id': data['id']}),
				requestor({'tariff': data}, 'ok'))

		self.assertEquals(wapi_tariffs.tariffGet({'id':''}),
				requestor({'message': 'Tariff not found' }, 'error'))

		with mocker([('bc.tariffs.get', mocker.exception),
					('bc_wapi.wapi_tariffs.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_tariffs.tariffGet({'id':''}),
				requestor({'message': 'Unable to obtain tariff' }, 'servererror'))
Exemplo n.º 6
0
	def test_tariff_get_list(self):
		"""Check getting tariffs with tariffList"""

		data = []
		for i in range(2, 10):
			d = {
				'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,
			}

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

			data.append(d)

		ans = wapi_tariffs.tariffList('')
		self.assertEquals(ans[0], (01 << 2))
		self.assertEquals(ans[1]['status'], 'ok')

		self.assertEquals(set(map(lambda x: hashable_dict(x), ans[1]['tariffs'])),
				set(map(lambda x: hashable_dict(x), data)))

		with mocker([('bc.tariffs.get_all', mocker.exception),
					('bc_wapi.wapi_tariffs.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_tariffs.tariffList({'id':''}),
				requestor({'message': 'Unable to obtain tariff list' }, 'servererror'))
Exemplo n.º 7
0
	def test_BCClient_exceptions(self):
		"""Check exceptions"""
		with mocker([('httplib.HTTPConnection', mocker.exception),
			('bc_client.client.LOG.error', mocker.passs)]):
			with self.assertRaises(Exception):
				BCClient('host','auth','timeout',{'a':'status'})

		with mocker([
			('bc_jsonrpc.http.jsonrpc_http_request',
				lambda *args, **kwargs: {'error':{'code':-32001}}),
			('httplib.HTTPConnection',
				lambda *a, **k: mocker.mockclass(connect=mocker.passs) ),
			('bc_client.client.LOG.error',
				mocker.passs)]):
			with self.assertRaises(BillingError):
				BCClient('host','auth','timeout',{'a':'status'}).a()
Exemplo n.º 8
0
	def test_rate_remove(self):
		"""Check state changing with rateRemove"""

		data = {
				'id':           str(uuid.uuid4()),
				'description':  str(uuid.uuid4()),
				'metric_id':    str(uuid.uuid4()),
				'tariff_id':    str(uuid.uuid4()),
				'rate':         long(random.randint(10**3, 10**10)),
				'currency':     rates.constants.CURRENCY_RUB,
				'state':        rates.constants.STATE_ACTIVE,
				'time_create':  int(time.time()),
				'time_destroy': 0,
				'sync':         0,
		}

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

		wapi_rates.rateRemove({'metric_id':data['metric_id'],
			'tariff_id':data['tariff_id']})

		data['state'] = rates.constants.STATE_DELETED
		data['time_destroy'] = int(time.time())

		with database.DBConnect() as db:
			t1 = db.find_one('rates', {'id': data['id']})

		self.assertEquals(hashable_dict(t1), hashable_dict(data.copy()))

		with mocker([('bc.rates.remove', mocker.exception),
					('bc_wapi.wapi_rates.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_rates.rateRemove({'id':''}),
				requestor({'message': 'Unable to remove rate' }, 'servererror'))
Exemplo n.º 9
0
	def test_customers_modification(self):
		""" Check modification attributes with customerModify"""

		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,
			'sync': 0,
			}

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

		self.assertEqual(wapi_customers.customerModify({'id':data['id']}),
				requestor({}, 'ok'))

		data1 = {
			'id':           data['id'],
			'contact_email':str(uuid.uuid4()),
			'tariff_id':    str(uuid.uuid4()),
		}

		data.update(data1)

		self.assertEqual(wapi_customers.customerModify(data1.copy()),
				requestor({}, 'ok'))

		with mocker([('bc.customers.modify', mocker.exception),
					('bc_wapi.wapi_customers.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_customers.customerModify(data1.copy()),
				requestor({'message': 'Unable to modify customer' }, 'servererror'))

		self.assertEqual(
			wapi_customers.customerModify({'id':'','state':customers.constants.STATE_DELETED}),
			requestor({'message': 'Wrong state: ' + str(customers.constants.STATE_DELETED)}, 'error'))

		self.assertEqual(
			wapi_customers.customerModify({'id':'','wallet_mode':''}),
			requestor({'message': 'Wrong wallet_mode: ' }, 'error'))


		with database.DBConnect() as db:
			t1 = db.find_one('customers', {'id': data['id']})

		self.assertEquals(t1, data)
Exemplo n.º 10
0
	def test_BCClient_init(self):
		"""Check creaing billing client object"""
		method_list = dict([(''.join(random.choice(string.ascii_letters) for x in xrange(10)), 'status') for y in xrange(random.randint(5,15))])
		with mocker([
			('httplib.HTTPConnection',
				lambda *a, **k: mocker.mockclass(connect=mocker.passs) )]):
			a = BCClient('host','auth','timeout',method_list)

		self.assertEquals(set(dir(a)), set(dir(object) + method_list.keys() + [
			'__dict__',
			'__module__',
			'__weakref__',
			'_BCClient__request',
			'conn',
			]))
Exemplo n.º 11
0
	def test_tariff_modification(self):
		""" Check modification attributes with tariffModify"""

		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,
			'sync':         0,
		}

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

		self.assertEqual(wapi_tariffs.tariffModify({'id':data['id']}),
				requestor({}, 'ok'))

		data1 = {
			'id':           data['id'],
			'name':         str(uuid.uuid4()),
			'description':  str(uuid.uuid4()),
		}

		data.update(data1)


		self.assertEqual(wapi_tariffs.tariffModify(data1),
				requestor({}, 'ok'))


		with mocker([('bc.tariffs.modify', mocker.exception),
					('bc_wapi.wapi_tariffs.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_tariffs.tariffModify(data1),
				requestor({'message': 'Unable to modify tariff' }, 'servererror'))

		self.assertEqual(
			wapi_tariffs.tariffModify({'id':'','state':tariffs.constants.STATE_DISABLED}),
			requestor({'message': 'Wrong state: ' + str(tariffs.constants.STATE_DISABLED)}, 'error'))

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

		self.assertEquals(t1, data)
Exemplo n.º 12
0
	def test_rate_modification(self):
		""" Check modification attributes with rateModify"""

		data = {
				'id':           str(uuid.uuid4()),
				'description':  str(uuid.uuid4()),
				'metric_id':    str(uuid.uuid4()),
				'tariff_id':    str(uuid.uuid4()),
				'rate':         long(random.randint(10**3, 10**10)),
				'currency':     rates.constants.CURRENCY_RUB,
				'state':        rates.constants.STATE_ACTIVE,
				'time_create':  int(time.time()),
				'time_destroy': 0,
				'sync':         0,
		}

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

		self.assertEqual(wapi_rates.rateModify({'metric_id':data['metric_id'],
												'tariff_id':data['tariff_id']}),
												requestor({'message': 'More arguments required'}, 'error'))

		with mocker([('bc.rates.modify', mocker.exception),
					('bc_wapi.wapi_rates.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_rates.rateModify({'id':data['id'], 'rate':10}),
				requestor({'message': 'Unable to modify rate' }, 'servererror'))

		self.assertEqual(
				wapi_rates.rateModify({'metric_id':'','tariff_id':'','currency':'ASD'}),
			requestor({'message': 'Wrong currency: ASD'}, 'error'))

		data1={'tariff_id':data['tariff_id'],
				'metric_id':data['metric_id'],
				'description':str(uuid.uuid4()),}
		data.update(data1)

		self.assertEqual(wapi_rates.rateModify(data1),
				requestor({}, 'ok'))

		with database.DBConnect() as db:
			t1 = db.find_one('rates', {'id': data['id']})

		self.assertEquals(hashable_dict(t1), hashable_dict(data))
Exemplo n.º 13
0
	def test_customers_get_list(self):
		"""Check getting customers with customerList"""

		cus = []
		for i in range(25):
			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': random.choice([customers.constants.STATE_ENABLED,
										customers.constants.STATE_DELETED,
										customers.constants.STATE_DISABLED]),
				'time_create': int(time.time()),
				'time_destroy': 0,
				'wallet': 10,
				'wallet_mode': customers.constants.WALLET_MODE_LIMITED
				}

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

			cus.append(data)

		ans = wapi_customers.customerList('')
		self.assertEquals(ans[0], (01 << 2))
		self.assertEquals(ans[1]['status'], 'ok')

		self.assertEquals(set(map(lambda x: hashable_dict(x), ans[1]['customers'])),
				set(map(lambda x: hashable_dict(x),
					filter(lambda x: x['state'] == customers.constants.STATE_ENABLED, cus))))

		with mocker([('bc.customers.get_all', mocker.exception),
					('bc_wapi.wapi_customers.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_customers.customerList({'id':''}),
				requestor({'message': 'Unable to obtain customer list' }, 'servererror'))
Exemplo n.º 14
0
	def test_customer_remove(self):
		"""Check state changing with customerRemove"""

		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,
			'sync': 0,
		}

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

		self.assertEquals(wapi_customers.customerRemove({'id':data['id']}),
				requestor({}, 'ok'))

		data['state'] = customers.constants.STATE_DELETED
		data['time_destroy'] = int(time.time())

		with database.DBConnect() as db:
			t1 = db.find_one('customers', {'id': data['id']})

		self.assertEquals(t1, data)

		with mocker([('bc.customers.remove', mocker.exception),
					('bc_wapi.wapi_customers.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_customers.customerRemove({'id':''}),
				requestor({'message': 'Unable to remove customer' }, 'servererror'))
Exemplo n.º 15
0
	def test_tariff_add_internal(self):
		"""Check the creating tariff with tariffAddInternal"""

		data={
			'id': str(uuid.uuid4()),
			'name': str(uuid.uuid4()),
			'description': str(uuid.uuid4()),
		}
		ans = wapi_tariffs.tariffAdd(data)

		self.assertEquals(ans, requestor({'id':data['id']}, 'ok'))

		with database.DBConnect() as db:
			t1 = db.find_one('tariffs', {'id': data['id']})
		self.assertEquals(data['name'], t1['name'])
		self.assertEquals(data['description'], t1['description'])

		with mocker([('bc.tariffs.add', mocker.exception),
					('bc_wapi.wapi_tariffs.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_tariffs.tariffAdd({'id':''}),
				requestor({'message': 'Unable to add new tariff' }, 'servererror'))
Exemplo n.º 16
0
	def test_metric_add(self):
		"""Check the creating metric with metricAdd"""

		data={
			'id':         str(uuid.uuid4()),
			'type':       str(uuid.uuid4())[:10],
			'formula':    metrics.constants.FORMULA_SPEED,
			'aggregate':  0L,
		}
		ans = wapi_metrics.metricAdd(data.copy())

		self.assertEquals(ans, requestor({'id':data['id']}, 'ok'))

		with database.DBConnect() as db:
			t1 = db.find('metrics').one()
		self.assertEquals(data['id'], t1['id'])
		self.assertEquals(data['type'], t1['type'])

		with mocker([('bc.metrics.add', mocker.exception),
					('bc_wapi.wapi_metrics.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_metrics.metricAdd({'id':''}),
				requestor({'message': 'Unable to add new metric' }, 'servererror'))
Exemplo n.º 17
0
	def test_metric_get(self):
		"""Check getting metric with metricGet"""

		data={
				'id':         str(uuid.uuid4()),
				'type':       str(uuid.uuid4())[:10],
				'formula':    metrics.constants.FORMULA_SPEED,
				'aggregate':  0L,
			}

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

		self.assertEquals(wapi_metrics.metricGet({'id': data['id']}),
				requestor({'metric': data}, 'ok'))

		self.assertEquals(wapi_metrics.metricGet({'id':''}),
				requestor({'message': 'Metric not found' }, 'error'))

		with mocker([('bc.metrics.get', mocker.exception),
					('bc_wapi.wapi_metrics.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_metrics.metricGet({'id':''}),
				requestor({'message': 'Unable to obtain metric' }, 'servererror'))
Exemplo n.º 18
0
			'currency':     rates.constants.CURRENCY_RUB,
			'state':        rates.constants.STATE_ACTIVE,
			'time_create':  int(time.time()),
			'time_destroy': 0,
		}

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

		self.assertEquals(wapi_rates.rateGet({
			'metric_id': data['metric_id'],
			'tariff_id': data['tariff_id'],
			}),
				requestor({'rate': data}, 'ok'))

		with mocker([('bc.rates.get_by_metric', mocker.exception),
					('bc_wapi.wapi_rates.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_rates.rateGet({'id':''}),
				requestor({'message': 'Unable to obtain rate list' }, 'servererror'))


	def test_rate_get_list(self):
		"""Check getting rates with rateList"""

		tariffs_list = [str(uuid.uuid4()) for i in range(5)]
		metrics_list = [str(uuid.uuid4()) for i in range(5)]

		rat = {}
		for tar in tariffs_list:
			rat[tar] = {}
			random.shuffle(metrics_list)
			for met in metrics_list[:random.randint(1, 5)]:
Exemplo n.º 19
0
			'sync': 0,
		}
		ans = wapi_customers.customerAdd(data.copy())

		self.assertEquals(ans, requestor({'id':data['id']}, 'ok'))

		with database.DBConnect() as db:
			t1 = db.find('customers').one()
		data['wallet_mode'] = customers.constants.WALLET_MODE_UNLIMITED
		self.assertEquals(data, t1)

		self.assertEquals(wapi_customers.customerAdd({'id':'',
			'wallet_mode':'',
			'name_short':''}), requestor({'message': 'Wrong wallet_mode: ' }, 'error'))

		with mocker([('bc.customers.add', mocker.exception),
					('bc_wapi.wapi_customers.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_customers.customerAdd({'id':''}),
				requestor({'message': 'Unable to add new customer' }, 'servererror'))


	def test_customer_remove(self):
		"""Check state changing with customerRemove"""

		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()),
Exemplo n.º 20
0
	def test_rate_get_list(self):
		"""Check getting rates with rateList"""

		tariffs_list = [str(uuid.uuid4()) for i in range(5)]
		metrics_list = [str(uuid.uuid4()) for i in range(5)]

		rat = {}
		for tar in tariffs_list:
			rat[tar] = {}
			random.shuffle(metrics_list)
			for met in metrics_list[:random.randint(1, 5)]:

				data = {
					'id':           str(uuid.uuid4()),
					'description':  str(uuid.uuid4()),
					'metric_id':    met,
					'tariff_id':    tar,
					'rate':         random.randint(10**3, 10**10),
					'currency':     rates.constants.CURRENCY_RUB,
					'state':        random.choice([rates.constants.STATE_ACTIVE,
										rates.constants.STATE_DELETED,
										rates.constants.STATE_UPDATE]),
					'time_create':  int(time.time()),
					'time_destroy': 0,
					}

				rat[tar][met] = data

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

		list_all = itertools.chain(*[rat[j].itervalues() for j in rat.iterkeys()])

		ans = wapi_rates.rateList('')
		self.assertEquals(ans[0], (01 << 2))
		self.assertEquals(ans[1]['status'], 'ok')

		self.assertEquals(
			set(map(lambda x: hashable_dict(x), ans[1]['rates'])),
			set(map(lambda x: hashable_dict(x),
				filter(lambda x:x['state'] < rates.constants.STATE_DELETED,
					list_all)
				)
			)
		)

		for tar_id in rat.keys():
			ans = wapi_rates.rateList({'tariff_id':tar_id})
			self.assertEquals(ans[0], (01 << 2))
			self.assertEquals(ans[1]['status'], 'ok')

			self.assertEquals(
				set(map(lambda x: hashable_dict(x), ans[1]['rates'])),
				set(map(lambda x: hashable_dict(x),
					filter(lambda x:x['state'] < rates.constants.STATE_DELETED,
						rat[tar_id].values())
					)
				)
			)

		with mocker([('bc.rates.get_all', mocker.exception),
					('bc_wapi.wapi_rates.LOG.error', mocker.passs)]):
			self.assertEquals(wapi_rates.rateList({'id':''}),
				requestor({'message': 'Unable to obtain rate list' }, 'servererror'))