def setUpClass(cls): # Setup a connection to the config db. cls.config_db = config_database.ConfigDB() # Set the ConfigDB's secret. cdb = config_database.ConfigDB() secret = 'ok' cdb['bts_secret'] = secret # Create a simplified checkin response with just status info. cls.checkin_response_template = { 'status': '', }
def setUpClass(cls): # Setup the config db. cls.config_db = config_database.ConfigDB() cls.config_db['bts_secret'] = 'hokay' cls.config_db['free_seconds'] = '5' cls.config_db['billable_unit'] = '1' # Setup some price data like what would be sent back from the cloud. price_data = [{ 'directionality': 'off_network_send', 'prefix': '509', 'country_name': 'Haiti', 'country_code': 'HT', 'cost_to_subscriber_per_sms': 900, 'cost_to_subscriber_per_min': 1100, 'billable_unit': 1, }, { 'directionality': 'off_network_send', 'prefix': '56', 'country_name': 'Chile', 'country_code': 'CL', 'cost_to_subscriber_per_sms': 1000, 'cost_to_subscriber_per_min': 800, 'billable_unit': 1, }, { 'directionality': 'off_network_send', 'prefix': '63', 'country_name': 'Philippines', 'country_code': 'PH', 'cost_to_subscriber_per_sms': 100, 'cost_to_subscriber_per_min': 600, 'billable_unit': 30, }, { 'directionality': 'off_network_receive', 'cost_to_subscriber_per_sms': 200, 'cost_to_subscriber_per_min': 100, 'billable_unit': 1, }, { 'directionality': 'on_network_send', 'cost_to_subscriber_per_sms': 400, 'cost_to_subscriber_per_min': 300, 'billable_unit': 1, }, { 'directionality': 'on_network_receive', 'cost_to_subscriber_per_sms': 500, 'cost_to_subscriber_per_min': 200, 'billable_unit': 1, }] # Populate the config db with prices process_prices(price_data, cls.config_db)
def fsapi(session, stream, env, args): """ Args: string config key Does not return anything, but writes to output the value of the config key in the ConfigDB if it exists, or to the empty string otherwise. """ cdb = config_database.ConfigDB() key = args.strip() try: res = cdb[key].strip() except KeyError: res = "" consoleLog('info', "ConfigDB FSAPI %s -> %s" % (key, res)) stream.write(res)
def chat(message, args): """ Args: string config key Does not return anything, but sets the variable "_endaga_ret" to the value of the config key in the ConfigDB if it exists, or to the empty string otherwise. """ cdb = config_database.ConfigDB() key = args.strip() try: res = cdb[key].strip() except KeyError: res = "" consoleLog('info', "ConfigDB Chat %s -> %s" % (key, res)) message.chat_execute('set', '_endaga_ret=%s' % res)
def setUpClass(cls): # Setup the autoupgrade data to be processed. We will process the data # once in this setUpClass method and then make assertions on the # results in the tests. checkin_response = json.dumps({ 'response': { 'config': { 'autoupgrade': { 'enabled': True, 'channel': 'beta', 'in_window': True, 'window_start': '02:30:00', 'latest_stable_version': '4.3.21', 'latest_beta_version': '8.7.65', }, }, } }) # Send the checkin response data for processing. CheckinHandler(checkin_response) # Setup a config db connection. cls.config_db = config_database.ConfigDB()
def setUp(self): self.checkin_response = {'response': {'subscribers': {}}} # handcrafted, artisinal PNCounters bal1 = {'p': {'3c470c85': 5000}, 'n': {'3c470c85': 0}} bal2 = {'p': {'26e7cbac': 15000}, 'n': {'26e7cbac': 5000}} self.sub1 = 'IMSI000112222233333' self.sub2 = 'IMSI000112222244444' self.sub_section = { self.sub1: { 'numbers': ['123456'], 'balance': bal1, }, self.sub2: { 'numbers': ['765432'], 'balance': bal2, } } self.config_db = config_database.ConfigDB()
def setUpClass(cls): # Setup the config db. cls.config_db = config_database.ConfigDB() cls.config_db['bts_secret'] = 'yup' # Load up some pricing data into the config db. We use this data to # determine what prefixes are available. # 2015dec9(shasan): This is a legacy billing response, lacking billable # units. This also tests we can handle that case. price_data = [{ 'directionality': 'off_network_send', 'prefix': '789', 'country_name': 'Ocenaia', 'country_code': 'OC', 'cost_to_subscriber_per_sms': 300, 'cost_to_subscriber_per_min': 20, }, { 'directionality': 'off_network_send', 'prefix': '78', 'country_name': 'Eurasia', 'country_code': 'EU', 'cost_to_subscriber_per_sms': 400, 'cost_to_subscriber_per_min': 10, }, { 'directionality': 'off_network_send', 'prefix': '7', 'country_name': 'Eastasia', 'country_code': 'EA', 'cost_to_subscriber_per_sms': 500, 'cost_to_subscriber_per_min': 30, }, { 'directionality': 'off_network_send', 'prefix': '3', 'country_name': 'London', 'country_code': 'LN', 'cost_to_subscriber_per_sms': 5000, 'cost_to_subscriber_per_min': 3000, }] # Populate the config db with prices process_prices(price_data, cls.config_db)
def setUpClass(cls): # Setup the price data to be processed. We will process the data once # in this setUpClass method and then make assertions on the results in # the tests. price_data = [{ 'directionality': 'off_network_send', 'prefix': '509', 'country_name': 'Haiti', 'country_code': 'HT', 'cost_to_subscriber_per_sms': 900, 'cost_to_subscriber_per_min': 1100, }, { 'directionality': 'off_network_send', 'prefix': '56', 'country_name': 'Chile', 'country_code': 'CL', 'cost_to_subscriber_per_sms': 1000, 'cost_to_subscriber_per_min': 800, }, { 'directionality': 'off_network_receive', 'cost_to_subscriber_per_sms': 200, 'cost_to_subscriber_per_min': 100, }, { 'directionality': 'on_network_send', 'cost_to_subscriber_per_sms': 30, 'cost_to_subscriber_per_min': 40, }, { 'directionality': 'on_network_receive', 'cost_to_subscriber_per_sms': 10, 'cost_to_subscriber_per_min': 20, }] # Setup a config db connection. cls.config_db = config_database.ConfigDB() # Populate the config db with prices process_prices(price_data, cls.config_db)
def setUpClass(cls): cls.config_db = config_database.ConfigDB() cls.upgrade_method = 'core.system_utilities.upgrade_endaga' cls.config_db['registration_interval'] = 60
def setUpClass(cls): cls.config_db = config_database.ConfigDB()
import os import random import re import sqlite3 import time from core import config_database from core import events from core import freeswitch_strings from core.sms import sms from core.subscriber import subscriber from core.exceptions import SubscriberNotFound config_db = config_database.ConfigDB() gt = gettext.translation("endaga", config_db['localedir'], [config_db['locale'], "en_US"]).ugettext def _init_pending_transfer_db(): """Create the pending transfers table if it doesn't already exist.""" db_create_str = ( "CREATE TABLE pending_transfers (code VARCHAR(5) PRIMARY KEY," " time FLOAT, from_acct INTEGER, to_acct INTEGER, amount INTEGER);") try: with open(config_db['pending_transfer_db_path']) as _: pass except IOError: db = sqlite3.connect(config_db['pending_transfer_db_path']) db.execute(db_create_str)