def rateGet(params): try: ret = rates.get_by_metric(params["tariff_id"], params["metric_id"]) if not ret: srv = zones.write_zone(params["tariff_id"]) if not srv["local"]: return jsonrpc.result({"status": "redirect", "server": srv["server"]}) return jsonrpc.result_error("InvalidRequest", {"status": "error", "message": "Rate not found"}) except Exception, e: LOG.error(e) return jsonrpc.result_error("ServerError", {"status": "error", "message": "Unable to obtain rate list"})
def test_rates_get(self): """Check getting rate from db""" data = { 'id': str(uuid.uuid4()), 'description': u'', 'metric_id': str(uuid.uuid4()), 'tariff_id': str(uuid.uuid4()), 'rate': 0L, 'currency': rates.constants.CURRENCY_RUB, 'state': rates.constants.STATE_ACTIVE, 'time_create': int(time.time()), 'time_destroy': 0 } rat = rates.Rate(data) with database.DBConnect() as db: db.insert('rates', data) self.assertEquals(rates.get_by_metric(rat.tariff_id, rat.metric_id), rat)