示例#1
0
文件: admin.py 项目: sridwan/meong
 def bundle(self, name, agent_id, price, pin):
     bc = AgentNotifier()
     c_agent = DBCache(const.AGENT_PREFIX, config.DEFAULT_EXPIRE,
                       const.AGENT_SQL)
     c_agent.setConn(bc.dbconn, bc.cacheconn)
     dm = DepositMutation(20, bc.dbconn, bc.cacheconn)
     ag = c_agent.sGet(agent_id)
     if not ag:
         return json.dumps({'success': 0, 'reason': 'AGENT NOT FOUND'})
     sql = '''SELECT * FROM `bundle` WHERE `bundle_name`=%s'''
     c = bc.dbconn.cursor(MySQLdb.cursors.DictCursor)
     c.execute(sql, (name,))
     cs = c.fetchall()
     if len(cs) == 0:
         return json.dumps({'success': 0, 'reason': 'BUNDLE NOT FOUND'})            
     balance = dm.debit(agent_id, int(price), 'Bundle {0}'.format(name))
     if balance < 0:
         return json.dumps({'success': 0, 'reason': 'NOT ENOUGH DEPOSIT'})
     um = UnitMutation(5, bc.dbconn, bc.cacheconn)
     for r in c:
         um.credit(agent_id, r['product_id'], r['unit'], 0, name)
     msg = 'Add bundle {0} to {1}-{2} Rp {3}'.\
           format(name, agent_id, ag['agent_name'], thousandSeparator(price))
     for prot in ('ym://b_martian','ym://inileonard', 'ym://sridwan981'):
         bc.writeNotifyOut(prot, 'general_message', {'message': msg})
     bc.dbconn.commit()
     return json.dumps({'success': 1, 'reason': ''})            
示例#2
0
文件: admin.py 项目: sridwan/meong
 def depmut_execute(self, agent_id, type, amount, comment, pin):
     result = {
       'success': 0,
       'balance': 0,
     }
     try:
         int(amount)
     except:
         result['message'] = 'AMOUNT NOT VALID'
         return json.dumps(result)
     # agent must exist
     bc = AgentNotifier()
     c_agent = DBCache(const.AGENT_PREFIX, config.DEFAULT_EXPIRE,
                       const.AGENT_SQL)
     c_agent.setConn(bc.dbconn, bc.cacheconn)
     #print c_agent.sGet(agentid)
     ag = c_agent.sGet(agent_id)
     if not ag:
         result['message'] = 'AGENT NOT REGISTERED'
         return json.dumps(result)
     dm = DepositMutation(20, bc.dbconn, bc.cacheconn)
     prev_bal = dm.getBalance(agent_id)
     if type.upper() == 'C':
         balance = dm.credit(agent_id, int(amount), comment)
         bc.writeNotifyOut(ag['default_protocol'], 'deposit_credit', {
                 'mutation': thousandSeparator(amount),
                 'balance_before': thousandSeparator(prev_bal),
                 'balance': thousandSeparator(balance),
             })
     elif type.upper() == 'D':
         balance = dm.debit(agent_id, int(amount), comment)
         bc.writeNotifyOut(ag['default_protocol'], 'deposit_debit', {
                 'mutation': thousandSeparator(amount),
                 'balance_before': thousandSeparator(prev_bal),
                 'balance': thousandSeparator(balance),
             })
     else:
         result['message'] = 'TYPE NOT RECOGNIZED'
         return json.dumps(result)
     if balance == NOT_ENOUGH_BALANCE:
         result['message'] = 'NOT ENOUGH BALANCE'
         return json.dumps(result)
     elif balance == LOCK_FAILED:
         result['message'] = 'SERVER BUSY'
         return json.dumps(result)
     bc.dbconn.commit()
     msg = '{0}-{1} Deposit: Rp. {2} Before: Rp. {3} After: Rp. {4} ({5}) ID:{6}'.\
           format(ag['agent_id'], ag['agent_name'], thousandSeparator(amount),
                  thousandSeparator(prev_bal), thousandSeparator(balance),
                  comment, dm.last_id)
     for prot in ('ym://b_martian','ym://inileonard', 'ym://sridwan981'):
         bc.writeNotifyOut(prot, 'general_message', {'message': msg})
     bc.dbconn.commit()
     result.update({
         'success': 1,
         'message': 'SUCCESS',
         'balance': balance,
         'mutation_id': dm.last_id,
     })
     return json.dumps(result)
示例#3
0
class TestCoreLeaf(TestCoreComponent):
    def setUp(self):
        super(TestCoreLeaf, self).setUp()
        self.cacheconn.flush_all()
        self.setUpTable()
        createProcess(notifyOut, prNotifyIn, prConfigHandler, prTopupParser,
                      prAuthorizer, prLoadBalance, prHighPrioritySync,
                      prLowPrioritySync)
        HLRCacheForLB(self.dbconn, self.cacheconn).cacheAllTopupDevice()
        time.sleep(8)
        self.c_message = DBCache(const.MESSAGE_PREFIX, config.DEFAULT_EXPIRE,
                                 const.MESSAGE_SQL)
        self.c_message.setConn(self.dbconn, self.cacheconn)
        showPID()
        self.leaf = leaf.Leaf(
            testmode=True,
            testcom=[
                ('COM10', script.ME_WAVECOMGSM, '201001240601026'),
                ('COM11', script.ME_WAVECOMGSM, '201001240600838'),
                ('COM20', script.ME_WAVECOMGSM, '201001240600135'),
                ('COM21', script.ME_WAVECOMGSM, '201001240600994'),
                ('COM22', script.ME_WAVECOMGSM, '201001240601067'),
                ('COM23', script.ME_WAVECOMGSM, '201001240601042'),
                ('COM24', script.ME_WAVECOMGSM, '201001240600671'),
                ('COM25', script.ME_SIEMENSC55, '351011513521015'),
                ('COM26', script.ME_SIEMENSC55, '010348005275525'),
                ('COM27', script.ME_NOKIA6235I, '03316190103'),
                ('COM30', script.ME_WAVECOMGSM, '201001240600655'),
                ('COM5', script.ME_WAVECOMGSM, '201001240600259'),
                ('COM50', script.ME_WAVECOMGSM, '111'),
                ('COM51', script.ME_WAVECOMGSM, '112'),
                ('COM52', script.ME_WAVECOMGSM, '113'),
                ('COM53', script.ME_WAVECOMGSM, '114'),
                ('COM54', script.ME_WAVECOMGSM, '115'),
                ('COM6', script.ME_WAVECOMGSM, '201001240600762'),
                ('COM7', script.ME_WAVECOMGSM, '201001240600564'),
                ('COM8', script.ME_WAVECOMGSM, '201001240600515'),
                ('COM9', script.ME_WAVECOMGSM, '201001240600515'),
            ])
#----------------------

    def tearDown(self):
        shutdown()
        self.leaf.shutdown()
        super(TestCoreLeaf, self).tearDown()
#----------------------

    def runTest(self):
        test_function = [x for x in dir(self) if x[:6] == 'srtest']
        map(lambda x: getattr(self, x)(), sorted(test_function))
#----------------------

    def srtest10_lawk_rdvl_dvls(self):
        r = self._waitForRow(
            'SELECT `command` from `notify_in` where `id`=1 and `status`=1', 5)
        self.assertEqual(r['command'], 'LAWK')
        self.leaf.processMessage()
        r = self._waitForRow(
            'SELECT `command` from `notify_in` where `id`=2 and `status`=1', 5)
        self.assertEqual(r['command'], 'DVLS')
        r = self._waitForRow(
            'SELECT `imei`,`brand` from `devices` WHERE '
            '`device_id`="server1.com26" and `status`=1', 5)
        self.assertEqual((r['imei'], r['brand']),
                         ('010348005275525', 'SIEMENS'))
#----------------------

    def srtest20_get_price(self):
        txt = '''

+CMGL: 1,"REC READ","+622196818889",,"{0}+28"
Harga.Ap10.0891

OK

'''.format(datetime.now().strftime('%y/%m/%d,%H:%M:%S'))
        self.leaf.result_q.put({
            'port': 'COM51',
            'cmd': 'csms',
            'id': 0,
            'status': True,
            'result': txt,
        })
        j = self.getQueue('COM51').get(1, 3)
        self.assertTrue('AT+CMGD=1' in j['ttl'])
        r = self._waitForRow(
            'SELECT `command` from `notify_in` where `id`=3 and `status`=1', 5)
        self.assertEqual(r['command'], 'UNMS')
        self.leaf.processMessage()
        j = self.getQueue('COM52').get(1, 3)
        self.assertTrue('AT+CMGS="02196818889' in j['ttl'])
#----------------------

    def srtest30_add_agent(self):
        txt = '''

+CMGL: 33,"REC READ","+622123881811",,"{0}+28"
Daftar#Selingkuhan 1#di hotel pastinyaa :)#0811911911#8888

OK

'''.format(datetime.now().strftime('%y/%m/%d,%H:%M:%S'))
        self.leaf.result_q.put({
            'port': 'COM50',
            'cmd': 'csms',
            'id': 0,
            'status': True,
            'result': txt,
        })
        j = self.getQueue('COM50').get(1, 3)
        self.assertTrue('AT+CMGD=33' in j['ttl'])
        r = self._waitForRow(
            'SELECT `command` from `notify_in` where `id`=4 and `status`=1', 5)
        self.assertEqual(r['command'], 'UNMS')
        r = self._waitForRow(
            'SELECT `agent_id`,`upline_id` from `agent` where `agent_id`="00004"',
            5)
        self.assertEqual(r['upline_id'], '00002')
        r = self._waitForRow(
            'SELECT `parameters` from `notify_out` where `id`=3 and `status`=1',
            5)
        # print r
        self.assertEqual(
            r['parameters'],
            'COM53,sms://02123881811,Agent Selingkuhan 1 telah terdaftar dengan ID: 00004.'
        )
        r = self._waitForRow(
            'SELECT `parameters` from `notify_out` where `id`=4 and `status`=1',
            5)
        # print r
        self.assertEqual(
            r['parameters'],
            'COM54,sms://0811911911,Agent Selingkuhan 1 telah terdaftar dengan ID: 00004.'
        )
        self.leaf.processMessage()
        self.leaf.processMessage()
        j = self.getQueue('COM53').get(1, 3)
        # print j
        self.assertTrue('AT+CMGS="02123881811' in j['ttl'])
        self.assertTrue('ID: 00004' in j['ttl'])
        j = self.getQueue('COM54').get(1, 3)
        # print j
        self.assertTrue('AT+CMGS="0811911911' in j['ttl'])
        self.assertTrue('ID: 00004' in j['ttl'])
#----------------------

    def srtest40_change_markup(self):
        txt = '''

+CMGL: 39,"REC READ","+622123881811",,"{0}+28"


markup.00004.100.8888



OK

'''.format(datetime.now().strftime('%y/%m/%d,%H:%M:%S'))
        self.leaf.result_q.put({
            'port': 'COM50',
            'cmd': 'csms',
            'id': 0,
            'status': True,
            'result': txt,
        })
        j = self.getQueue('COM50').get(1, 3)
        self.assertTrue('AT+CMGD=39' in j['ttl'])
        r = self._waitForRow(
            'SELECT `command` from `notify_in` where `id`=5 and `status`=1', 5)
        # print r
        self.assertEqual(r['command'], 'UNMS')
        r = self._waitForRow(
            'SELECT `sell_price`,`markup_upline` from `agent_price` '
            'WHERE `agent_id`="00004" and `product_id`="FR10"', 5)
        # print r
        self.assertEqual(r['sell_price'], 10300)
        self.assertEqual(r['markup_upline'], 100)
        r = self._waitForRow(
            'SELECT `parameters` from `notify_out` where `id`=5 and `status`=1',
            5)
        # print r
        self.assertTrue('markup' in r['parameters'])
        self.assertTrue('00004' in r['parameters'])
        self.assertTrue('100' in r['parameters'])
        self.leaf.processMessage()
        j = self.getQueue('COM52').get(1, 3)
        # print j
        self.assertTrue('AT+CMGS="02123881811' in j['ttl'])
        self.assertTrue('00004' in j['ttl'])
#----------------------

    def getQueue(self, port):
        return self.leaf.root[port]['queue']


#----------------------

    def setUpTable(self):
        self._resetTable('Transaction')
        self._resetTable('Notify_In')
        self._resetTable('Notify_Out')
        self._resetTable('Deposit_Mutation')
        self._resetTable('Deposit_Transfer')
        self._resetTable('Message')
        self._resetTable('Nin_Unknown')
        cursor = self.dbconn.cursor()
        cursor.execute('DELETE FROM `hlr_cache`')
        cursor.execute('DELETE FROM `devices`')
        cursor.execute(
            '''INSERT INTO `devices` (`device_id`, `server_id`, `port`, `active`, `imei`, `brand`, `type`, `operator_id`, `hlr_id`, `msidn_device`, `device_name`, `supplier_id`, `function`, `pin`, `status`, `expired_date`, `last_update`, `last_update_by`) VALUES
            ('SERVER1.COM10', 'SERVER1', 'COM10', 1, '201001240601026', 'WAVECOM', 'GSM', 2, 1, '', 'MKIOS1', 0, 3, '110', 0, '0000-00-00', '2010-11-19 17:40:39', ''),
            ('SERVER1.COM11', 'SERVER1', 'COM11', 1, '201001240600838', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '111', 0, '0000-00-00', '2011-01-12 16:42:41', ''),
            ('SERVER1.COM20', 'SERVER1', 'COM20', 1, '201001240600135', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '120', 0, '0000-00-00', '2011-01-12 16:42:47', ''),
            ('SERVER1.COM21', 'SERVER1', 'COM21', 1, '201001240600994', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '121', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM22', 'SERVER1', 'COM22', 1, '201001240601067', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '122', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM23', 'SERVER1', 'COM23', 1, '201001240601042', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '123', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM24', 'SERVER1', 'COM24', 1, '201001240600671', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '124', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM25', 'SERVER1', 'COM25', 1, '351011513521015', 'SIEMENS', 'C55', 1, 2, '', '', 0, 3, '125', 0, '0000-00-00', '2011-01-12 16:43:06', ''),
            ('SERVER1.COM26', 'SERVER1', 'COM26', 1, '010348005275525', 'SIEMENS', 'C55', 1, 3, '', '', 0, 3, '126', 0, '0000-00-00', '2011-01-12 16:43:06', ''),
            ('SERVER1.COM27', 'SERVER1', 'COM27', 1, '03316190103', 'NOKIA', '6235i', 1, 3, '', '', 0, 3, '127', 0, '0000-00-00', '2011-01-12 16:43:07', ''),
            ('SERVER1.COM30', 'SERVER1', 'COM30', 1, '201001240600655', 'WAVECOM', 'CDMA', 7, 7, '', '', 0, 3, '109', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM5', 'SERVER1', 'COM5', 1, '201001240600259', 'WAVECOM', 'GSM', 1, 3, '', '', 0, 3, '105', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM50', 'SERVER1', 'COM50', 1, '111', 'WAVECOM', 'GSM', 0, 0, '', '', 0, 1, '', 0, '0000-00-00', '2011-01-27 20:44:50', ''),
            ('SERVER1.COM51', 'SERVER1', 'COM51', 1, '112', 'WAVECOM', 'GSM', 0, 0, '', '', 0, 1, '', 0, '0000-00-00', '2011-01-27 20:44:50', ''),
            ('SERVER1.COM52', 'SERVER1', 'COM52', 1, '113', 'WAVECOM', 'GSM', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '2011-01-27 20:44:51', ''),
            ('SERVER1.COM53', 'SERVER1', 'COM53', 1, '114', 'WAVECOM', 'GSM', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '2011-01-27 20:44:52', ''),
            ('SERVER1.COM54', 'SERVER1', 'COM54', 1, '115', 'WAVECOM', 'GSM', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '2011-01-27 20:44:53', ''),
            ('SERVER1.COM6', 'SERVER1', 'COM6', 1, '201001240600762', 'WAVECOM', 'GSM', 1, 3, '', '', 0, 3, '106', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM7', 'SERVER1', 'COM7', 1, '201001240600564', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '107', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM8', 'SERVER1', 'COM8', 1, '201001240600515', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '108', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM9', 'SERVER1', 'COM9', 1, '201001240600515', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '109', 0, '0000-00-00', '2010-11-09 21:12:47', '')'''
        )
        cursor.execute('DELETE FROM `hlr`')
        cursor.execute(
            '''INSERT INTO `hlr` (`hlr_id`, `operator_id`, `location`, `hlr`, `last_update`, `last_update_by`) VALUES
            (1, 2, 'DKI Jakarta', '100,101,102,103', '2010-10-22 15:29:52', 'bernard'),
            (2, 1, 'Meong1', '110,111,112', '0000-00-00 00:00:00', 'test'),
            (3, 1, 'Meong2', '210,211,212', '0000-00-00 00:00:00', 'test'),
            (7, 7, 'Meong2', '021', '0000-00-00 00:00:00', 'test'),
            (4, 3, 'Guk1', '330,331,332', '0000-00-00 00:00:00', 'test')''')
        cursor.execute('DELETE FROM `operator`')
        cursor.execute(
            '''INSERT INTO `operator` (`operator_id`, `operator_name`, `type`, `prefix`, `stock_check_1`, `stock_check_2`, `sim_balance`, `last_update`, `last_update_by`) VALUES
          (1, 'Telkomsel', 'G', '0812,0813,0852,0853', 'ussd://*776*<pin>#', 'ussd://*676*<pin>#', 'ussd://*888#', '2010-11-17 17:34:44', ''),
          (2, 'Indosat', 'G', '0814,0815,0816,0855,0856,0857,0858', 'data://31.<pin>$', '', 'ussd://*388#', '2010-10-29 18:52:34', ''),
          (3, 'XL', 'G', '0817,0818,0819,0859,0877,0878', 'sms://balance,461', '', 'ussd://*123#', '2010-10-29 18:52:48', ''),
          (4, 'Three', 'G', '0894,0896,0898,0899', 'data://+13.<pin>$', '', '', '2010-10-20 15:08:41', ''),
          (5, 'Axis', 'G', '0831,0832,0833,0838', 'data://13.<pin>$', '', '', '2010-10-20 15:08:36', ''),
          (6, 'Fren', 'G', '0888,0889', '', '', '', '0000-00-00 00:00:00', ''),
          (7, 'Esia', 'C', '4,6,8,9', 'sms:// bal <pin>,898', '', 'sms://talktime,555', '2010-11-17 20:52:29', ''),
          (8, 'Flexi', 'C', '2,3,4,5,6,7,8,9', 'sms://qd#<pin,899', '', '', '2010-10-20 15:10:59', ''),
          (9, 'StarOne', 'C', '3,8', '', '', '', '0000-00-00 00:00:00', ''),
          (10, 'Hepi', 'C', '3,4,5', '', '', '', '0000-00-00 00:00:00', ''),
          (11, 'Smart', 'G', '0881,0882,0883,0884,0885,0886,0887', '', '', '', '0000-00-00 00:00:00', '')'''
        )
        cursor.execute('DELETE FROM `product`')
        cursor.execute(
            '''INSERT INTO `product` (`product_id`, `product_name`, `operator_id`, `active`, `point`, `operator_product_id_1`, `operator_product_id_2`, `operator_product_id_3`, `operator_product_id_4`, `operator_product_id_5`, `method_1`, `method_1_active`, `method_2`, `method_2_active`, `method_3`, `method_3_active`, `method_4`, `method_4_active`, `method_5`, `method_5_active`, `last_update`, `last_update_by`) VALUES
          ('A10', 'As 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, 'YM', 0, '', 0, '', 0, '2010-07-08 18:48:06', ''),
          ('A5', 'As 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:07', ''),
          ('AP10', 'As 10.000 Promo', 1, 1, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AP5', 'As 5.000 Promo', 1, 0, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AX10', 'Axis 10.000', 5, 1, 1, 'AXIS10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:09', ''),
          ('AX20', 'Axis 20.000', 5, 1, 1, 'AXIS20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('AX50', 'Axis 50.000', 5, 1, 1, 'AXIS50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('BR5', 'Broom 5.000', 2, 1, 1, 'INDOSAT5BROOM', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('E25', 'Esia 25.000', 7, 1, 1, 'ESIA25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('E50', 'Esia 50.000', 7, 1, 1, 'ESIA50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('F10', 'Flexi 10.000', 8, 1, 1, 'FLEXI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:12', ''),
          ('F20', 'Flexi 20.000', 8, 1, 1, 'FLEXI20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:16', ''),
          ('F5', 'Flexi 5.000', 8, 1, 1, 'FLEXI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR10', 'Fren 10.000', 6, 1, 1, 'FREN10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR20', 'Fren 20.000', 6, 1, 1, 'FREN20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:18', ''),
          ('FR25', 'Fren 25.000', 6, 1, 1, 'FREN25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H10', 'Hepi 10.000', 10, 1, 1, 'HEPI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H25', 'Hepi 25.000', 10, 1, 1, 'HEPI25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('H5', 'Hepi 5.000', 10, 1, 1, 'HEPI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('M10', 'Mentari 10.000', 2, 1, 1, 'INDOSAT10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:21', ''),
          ('M5', 'Mentari 5.000', 2, 1, 1, 'INDOSAT5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S10', 'Simpati 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S5', 'Simpati 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:23', ''),
          ('SM10', 'Smart 10.000', 11, 1, 1, 'SMART10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM20', 'Smart 20.000', 11, 1, 1, 'SMART20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM5', 'Smart 5.000', 11, 1, 1, 'SMART5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:25', ''),
          ('SO10', 'StarOne 10.000', 9, 1, 1, 'SO10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO20', 'StarOne 20.000', 9, 1, 1, 'SO20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO5', 'StarOne 5.000', 9, 1, 1, 'SO5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP10', 'Simpati 10.000 Promo', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP5', 'Simpati 5.000 Promo', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:28', ''),
          ('T10', 'Three 10.000', 4, 1, 1, 'THREE10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T20', 'Three 20.000', 4, 1, 1, 'THREE20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T5', 'Three 5.000', 4, 1, 1, 'THREE5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:30', ''),
          ('X10', 'XL 10.000', 3, 1, 1, 'XL10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', ''),
          ('X25', 'XL 25.000', 3, 1, 1, 'XL25', '', '', '', '', '', 0, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('X5', 'XL 5.000', 3, 1, 1, 'XL5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', '')'''
        )
        cursor.execute('DELETE FROM `balance`')
        cursor.execute(
            '''INSERT INTO `balance` (`device_id`, `topup_balance`, `last_update`, `last_update_by`) VALUES
          ('SERVER1.COM7', 100000, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM8', 100000, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM9', 100000, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 100000, '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `unit`')
        cursor.execute(
            '''INSERT INTO `unit` (`device_id`, `operator_product_id`, `balance_unit`, `last_update`, `last_update_by`) VALUES
          ('SERVER1.COM10', 'INDOSAT5', 20, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM10', 'INDOSAT10', 20, '2010-10-25 16:05:59', ''),
          ('SERVER1.COM11', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM11', 'INDOSAT10', 10, '2010-10-27 15:52:40', ''),
          ('SERVER1.COM20', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM20', 'INDOSAT10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM21', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM21', 'INDOSAT10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM22', 'AS10', 20, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM22', 'SIMPATI5', 20, '2010-10-25 16:05:59', ''),
          ('SERVER1.COM23', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM23', 'SIMPATI5', 10, '2010-10-27 15:52:40', ''),
          ('SERVER1.COM24', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM24', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM25', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM25', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM26', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM26', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM27', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM27', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 'ESIA5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 'ESIA10', 20, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM5', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM5', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM6', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM6', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM7', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM7', 'XL10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM8', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM8', 'XL10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM9', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM9', 'XL10', 10, '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `operator_product`')
        cursor.execute(
            '''INSERT INTO `operator_product` (`operator_product_id`, `balance_flag`, `unit_used`, `operator_id`, `topup_amount_chip`, `topup_parse`, `last_update`, `last_update_by`) VALUES
            ('AS10', 'U', 'AS10', 1, 0, 'ussd://*677*<dest>*10*<pin>#', '2010-10-27 15:41:47', 'admin'),
            ('AS100', 'U', 'AS100', 1, 0, 'ussd://*677*<dest>*100*<pin>#', '2010-10-27 15:41:50', 'admin'),
            ('AS15', 'U', 'AS15', 1, 0, 'ussd://*677*<dest>*15*<pin>#', '2010-10-27 15:41:53', 'admin'),
            ('AS20', 'U', 'AS20', 1, 0, 'ussd://*677*<dest>*20*<pin>#', '2010-10-27 15:41:56', 'admin'),
            ('AS25', 'U', 'AS25', 1, 0, 'ussd://*677*<dest>*25*<pin>#', '2010-10-27 15:41:59', 'admin'),
            ('AS5', 'U', 'AS5', 1, 0, 'ussd://*677*<dest>*5*<pin>#', '2010-10-27 15:42:02', 'admin'),
            ('AS50', 'U', 'AS50', 1, 0, 'ussd://*677*<dest>*50*<pin>#', '2010-10-27 15:42:05', 'admin'),
            ('AXIS10', 'B', '', 5, 10000, 'data://12.<dest>..<pin>$', '2010-10-27 15:47:38', 'admin'),
            ('AXIS100', 'B', '', 5, 100000, 'data://14.<dest>..<pin>$', '2010-10-27 15:47:38', 'admin'),
            ('AXIS20', 'B', '', 5, 20000, 'data://15.20000..<dest>..<pin>$', '2010-10-27 15:47:36', 'admin'),
            ('AXIS25', 'B', '', 5, 25000, 'data://13.<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('AXIS5', 'B', '', 5, 5000, 'data://11.<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('AXIS50', 'B', '', 5, 50000, 'data://15.50000..<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('ESIA1', 'U', 'ESIA1', 7, 1000, 'sms://isi <dest> 1 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA10', 'U', 'ESIA10', 7, 10000, 'sms://isi <dest> 10 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA11', 'B', '', 7, 11000, 'sms://isi <dest> 11 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA15', 'B', '', 7, 15000, 'sms://isi <dest> 15 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA20', 'B', '', 7, 20000, 'sms://isi <dest> 20 <pin>,898', '2010-10-27 15:47:33', 'admin'),
            ('ESIA5', 'U', 'ESIA5', 7, 5000, 'sms://isi <dest> 5 <pin>,898', '2010-10-27 15:47:33', 'admin'),
            ('FLEXI10', 'B', '', 8, 10000, 'sms://TOP#<pin>#<dest>#F10,899', '2010-10-27 15:47:32', 'admin'),
            ('FLEXI100', 'B', '', 8, 100000, 'sms://TOP#<pin>#<dest>#100,899', '2010-10-27 15:47:32', 'admin'),
            ('FLEXI20', 'B', '', 8, 20000, 'sms://TOP#<pin>#<dest>#F20,899', '2010-10-27 15:47:31', 'admin'),
            ('FLEXI5', 'B', '', 8, 5000, 'sms://TOP#<pin>#<dest>#F5,899', '2010-10-27 15:47:30', 'admin'),
            ('FLEXI50', 'B', '', 8, 50000, 'sms://TOP#<pin>#<dest>#50,899', '0000-00-00 00:00:00', 'admin'),
            ('INDOSAT10', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.11.<pin>$', '0000-00-00 00:00:00', 'admin'),
            ('INDOSAT100', 'U', 'INDOSAT100', 2, 0, 'data://11.<dest>.51.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT100BROOM', 'U', 'INDOSAT100', 2, 0, 'data://11.9<dest>.51.<pin>$', '2010-10-27 15:43:40', 'admin'),
            ('INDOSAT10BROOM', 'U', 'INDOSAT10', 2, 0, 'data://11.9<dest>.11.<pin>$', '2010-10-27 15:43:35', 'admin'),
            ('INDOSAT10GPRS', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.13.<pin>$', '2010-10-27 15:43:32', 'admin'),
            ('INDOSAT10SMS', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.12.<pin>$', '2010-10-27 15:43:29', 'admin'),
            ('INDOSAT25', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.31.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT25BROOM', 'U', 'INDOSAT25', 2, 0, 'data://11.9<dest>.31.<pin>$', '2010-10-27 15:43:26', 'admin'),
            ('INDOSAT25GPRS', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.33.<pin>$', '2010-10-27 15:43:21', 'admin'),
            ('INDOSAT25SMS', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.32.<pin>$', '2010-10-27 15:43:17', 'admin'),
            ('INDOSAT5', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.1.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT50', 'U', 'INDOSAT50', 2, 0, 'data://11.<dest>.41.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT50BROOM', 'U', 'INDOSAT50', 2, 0, 'data://11.9<dest>.41.<pin>$', '2010-10-27 15:43:13', 'admin'),
            ('INDOSAT5BROOM', 'U', 'INDOSAT5', 2, 0, 'data://11.9<dest>.6.5000.1.<pin>$', '2010-10-27 15:42:42', 'admin'),
            ('INDOSAT5GPRS', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.3.<pin>$', '2010-10-27 15:42:37', 'admin'),
            ('INDOSAT5SMS', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.2.<pin>$', '2010-10-27 15:42:33', 'admin'),
            ('SIMPATI10', 'U', 'SIMPATI10', 1, 0, 'ussd://*777*<dest>*10*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI100', 'U', 'SIMPATI100', 1, 0, 'ussd://*777*<dest>*50*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI20', 'U', 'SIMPATI20', 1, 0, 'ussd://*777*<dest>*20*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI5', 'U', 'SIMPATI5', 1, 0, 'ussd://*777*<dest>*5*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI50', 'U', 'SIMPATI50', 1, 0, 'ussd://*777*<dest>*25*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('THREE1', 'B', '', 4, 1000, 'data://+11.<dest>..<dest>..1000..1000..<pin>$', '2010-10-27 15:48:32', 'admin'),
            ('THREE10', 'B', '', 4, 10000, 'data://+11.<dest>..<dest>..10000..10000..<pin>$', '2010-10-27 15:48:33', 'admin'),
            ('THREE100', 'B', '', 4, 100000, 'data://+11.<dest>..<dest>..100000..100000..<pin>$', '2010-10-27 15:48:33', 'admin'),
            ('THREE2', 'B', '', 4, 2000, 'data://+11.<dest>..<dest>..2000..2000..<pin>$', '2010-10-27 15:48:34', 'admin'),
            ('THREE20', 'B', '', 4, 20000, 'data://+11.<dest>..<dest>..20000..20000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE3', 'B', '', 4, 3000, 'data://+11.<dest>..<dest>..3000..3000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE30', 'B', '', 4, 30000, 'data://+11.<dest>..<dest>..30000..30000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE4', 'B', '', 4, 4000, 'data://+11.<dest>..<dest>..4000..4000..<pin>$', '2010-10-27 15:48:38', 'admin'),
            ('THREE5', 'B', '', 4, 5000, 'data://+11.<dest>..<dest>..5000..5000..<pin>$', '2010-10-27 15:48:39', 'admin'),
            ('THREE50', 'B', '', 4, 50000, 'data://+11.<dest>..<dest>..50000..50000..<pin>$', '2010-10-27 15:48:39', 'admin'),
            ('XL1', 'U', 'XL1', 3, 0, 'USSD://*101*1000*00*<dest>*<pin>#', '2010-10-27 17:59:06', 'admin'),
            ('XL10', 'U', 'XL10', 3, 0, 'USSD://*101*10000*00*<dest>*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('XL100', 'B', '', 3, 100000, 'USSD://*101*100000*00*<dest>*<pin>#', '2010-10-27 15:47:18', 'admin'),
            ('XL25', 'B', '', 3, 25000, 'USSD://*101*25000*00*<dest>*<pin>#', '2010-10-27 15:47:15', 'admin'),
            ('XL5', 'U', 'XL5', 3, 0, 'USSD://*101*5000*00*<dest>*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('XL50', 'B', '', 3, 50000, 'USSD://*101*50000*00*<dest>*<pin>#', '2010-10-27 15:47:12', 'admin')'''
        )
        cursor.execute('DELETE FROM `agent`')
        cursor.execute(
            '''INSERT INTO `agent` (`agent_id`, `active`, `agent_name`, `agent_address`, `agent_type`, `pin`, `upline_id`, `markup`, `markup_upline`, `set_price`, `register_date`, `last_activity_date`, `last_update`, `last_update_by`) VALUES
            ('00001', 1, 'Bernard Martian', 'Test', 1, '9999', '', 100, 0, 'Test', '2010-11-09 18:24:44', '2010-11-09 18:24:51', '2010-11-24 00:50:12', ''),
            ('00002', 1, 'Stephanus Ridwan', 'PM', 1, '8888', '00001', 0, 100, 'Test', '2010-11-09 18:24:44', '2010-11-09 18:24:51', '2011-01-12 21:20:01', ''),
            ('00003', 1, 'Dewi Karyana', 'Depok', 1, '0891', '00002', 0, 100, 'Test', '2010-11-09 18:24:51', '2010-11-09 18:24:51', '2011-01-12 21:20:22', '')'''
        )
        cursor.execute('DELETE FROM `agent_price`')
        cursor.execute(
            '''INSERT INTO `agent_price` (`agent_id`, `product_id`, `sell_price`, `markup_upline`, `date_time`, `status`, `last_update`, `last_update_by`) VALUES
            ('00001', 'A10', 10150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'A5', 5150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'E25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'E50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'M10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'M5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'S10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'S5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'X10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'X5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00002', 'A10', 10250, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'A5', 5250, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AP10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AP5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX50', 50200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'E25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'E50', 50200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'M10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'M5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'S10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'S5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SP10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SP5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'X10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'X5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00003', 'A10', 10350, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'A5', 5350, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AP10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AP5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX50', 50300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'E25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'E50', 50300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'M10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'M5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'S10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'S5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SP10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SP5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'X10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'X5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', '')''')
        cursor.execute(
            '''INSERT INTO `deposit_mutation` (`deposit_mutation_id`, `timestamp`, `agent_id`, `mutation`, `type`, `deposit_balance`, `comment`) VALUES
            (1, '2011-01-12 22:00:51', '00001', 100000, 'C', 100000, 'Initial'),
            (2, '2011-01-12 22:01:29', '00002', 150000, 'C', 150000, 'Initial'),
            (3, '2011-01-12 22:01:51', '00003', 120000, 'C', 120000, 'Initial')'''
        )
        cursor.execute('DELETE FROM `message`')
        cursor.execute(
            '''INSERT INTO `message` (`name`, `description`, `parse`) VALUES
          ('agent_invalid', 'Invalid Agent', 'Agen tidak terdaftar atau PIN salah.'),
          ('agent_not_enough_balance', 'Not Enough Balance', 'Topup <product_id> gagal. Saldo tidak mencukupi. Sisa saldo <balance>.'),
          ('agent_not_frontline', 'Agent is not your downline', 'Agen <agent_id> bukan downline langsung.'),
          ('agent_not_reg', 'Agent not registered', 'Agent <agent_id> tidak terdaftar.'),
          ('amount_not_number', 'Amount transfer is not numeric', '<amount> bukan angka.'),
          ('amount_zero', 'Amount can not be zero', 'Jumlah transfer tidak boleh 0 (nol).'),
          ('change_frontlinemarkup_success', 'Markup Agent', 'Rubah markup agen <agent_id> BERHASIL. Markup baru: <markup>.'),
          ('change_globalmarkup_success', 'Markup Global', 'Rubah markup seluruh downline BERHASIL. Markup baru: <markup>.'),
          ('change_pin', 'Change PIN', 'Ganti PIN sukses. Pin baru adalah <pin>.'),
          ('deposit_level', 'Deposit', 'Deposit: <deposit>.'),
          ('hlr_not_supported', 'HLR Not Supported', 'Nomor tujuan <dest> di luar area kami.'),
          ('markup_is_zero', 'Markup can not be zero', 'Markup harus lebih besar dari 0.'),
          ('markup_not_number', 'Markup is not numeric', 'Markup <markup> bukan angka.'),
          ('num_op_dont_match', 'Operator not match with destination', 'Tujuan <dest> bukan jaringan <operator>.'),
          ('out_of_stock', 'Closed Product', 'Produk <product_id> tidak tersedia.'),
          ('product_price', 'Product Price', 'Harga <product_id>: <price>.'),
          ('prod_not_registered', 'Product not registered', 'Produk <product_id> tidak tersedia.'),
          ('register_new_agent', 'New Agent', 'Agen "<name>" memiliki kode agen: <agent_id>. PIN awal: 1234.'),
          ('topup_fail', 'Top up Fail', 'Topup tidak berhasil, <reason>.'),
          ('transaction_status', 'Transaction Status', 'Topup produk <product_id> untuk <dest> <status>'),
          ('transaction_successful', 'Transaction Report', 'Transaksi <product_id> untuk <dest> BERHASIL. Ref:<ref> saldo <balance>'),
          ('transfer_agent_not_enough_bal', 'Not Enough Balance', 'Saldo agen tidak cukup untuk transfer. Saldo agen <agent_id> <balance>.'),
          ('transfer_fail', 'Transfer Fail', 'Transfer untuk saat ini tidak dapat dilakukan. Cobalah beberapa saat lagi.'),
          ('transfer_not_enough_balance', 'Transfer Not Enough Balance', 'Saldo tidak mencukupi untuk transfer. Saldo anda <balance>.'),
          ('transfer_over_revoke', 'Transfer Over Revoke', 'Tidak bisa mengambil lebih banyak dari transfer harian. Sisa transfer hari ini <transfer>.'),
          ('transfer_status', 'Transfer Status', 'Transfer deposit agen <agent_id>, order ke-<order> sebesar <amount> BERHASIL.'),
          ('unknown_command', 'Unknown Command', 'Perintah tidak dikenal.'),
          ('wrong_req_format', 'Wrong Format', 'Format topup request tidak dikenal.'),
          ('wrong_transfer_format', 'Wrong Transfer Format', 'Format perintah transfer salah. Mohon cek kembali.'),
          ('add_agent_success', 'Add New Agent Success', 'Agent <name> telah terdaftar dengan ID: <agent_id>.')'''
        )
        cursor.execute('DELETE FROM `regprotocol`')
        cursor.execute(
            '''INSERT INTO `regprotocol` (`reg_protocol`, `agent_id`) VALUES
            ('sms://08161940700', '00001'),
            ('sms://02123881811', '00002'),
            ('ym://sridwan981', '00002'),
            ('sms://02196818889', '00003')''')
        self.dbconn.commit()
        cursor.close()
示例#4
0
class TestDepositMutation(TestAdminHelper):
#----------------------
    def setUp(self):
        self.bc = BaseComponent()
        self.dbconn = self.bc.dbconn
        self.cacheconn = self.bc.cacheconn
        self.cacheconn.delete('{0}_00001'.format(const.MUTATION_PREFIX))
        cursor = self.dbconn.cursor()
        self._resetTable('Deposit_Mutation')
        try:
            cursor.execute('''INSERT INTO `agent` (`agent_id`, `active`, `agent_name`,
              `agent_address`, `agent_type`, `pin`, `upline_id`, `markup`,
              `markup_upline`, `set_price`, `register_date`, `last_activity_date`,
              `last_update`, `last_update_by`) VALUES
              ('00001', 1, 'Bernard Martian', 'Test', 1, '9999', '', 100, 0, 'Test',
              '2010-11-09 18:24:44', '2010-11-09 18:24:51', '2010-11-24 00:50:12', '')''')
        except:
            pass
        cursor.close()
        self.dbconn.commit()

        self.c_agent = DBCache(const.AGENT_PREFIX, config.DEFAULT_EXPIRE,
          const.AGENT_SQL)
        self.c_agent.setConn(self.dbconn, self.cacheconn)
        self.dm = DepositMutation(2, self.dbconn, self.cacheconn)
#----------------------
    def runTest(self):
        test_function = [x for x in dir(self) if x[:6] == 'srtest']
        map(lambda x: getattr(self, x)(), sorted(test_function))
#----------------------
    def srtest010(self):
        balance = self.dm.debit('00001', 10000, 'srtest010')
        self.dbconn.commit()
        self.assertEqual(balance, depmut.NOT_ENOUGH_BALANCE)
        balance = self.dm.credit('00001', 10000, 'srtest010')
        self.dbconn.commit()
        self.assertEqual(balance, 10000)
        balance = self.dm.debit('00001', 5000, 'srtest010')
        self.dbconn.commit()
        self.assertEqual(balance, 5000)
#----------------------
    def srtest020_lock(self):
        self.dm.l_mutation.lockNoWait(self.cacheconn, '00001')
        balance = self.dm.credit('00001', 10000, 'srtest010')
        self.assertEqual(balance, depmut.LOCK_FAILED)
        self.dm.l_mutation.release(self.cacheconn, '00001')
#----------------------
    def srtest030_adminHelperDepositMutation(self):
        post_data = {
          'agent_id': '00001',
          'type': 'D',
          'amount': 5000
        }
        tmp = self._callAdminHelper('deposit_mutation', post_data)
        self.assertEqual(tmp['success'], 1)
        self.assertEqual(tmp['balance'], 0)
        tmp = self._callAdminHelper('deposit_mutation', post_data)
        self.assertEqual(tmp['success'], 0)
        self.assertEqual(tmp['message'], 'NOT ENOUGH BALANCE')
        post_data['type'] = 'X'
        tmp = self._callAdminHelper('deposit_mutation', post_data)
        self.assertEqual(tmp['success'], 0)
        self.assertEqual(tmp['message'], 'TYPE NOT RECOGNIZED')
        post_data['agent_id'] = 'xxx'
        tmp = self._callAdminHelper('deposit_mutation', post_data)
        self.assertEqual(tmp['success'], 0)
        self.assertEqual(tmp['message'], 'AGENT NOT REGISTERED')
#----------------------
    def tearDown(self):
        self.cacheconn.delete('{0}_00001'.format(const.MUTATION_PREFIX))
        self.dbconn.close()
示例#5
0
class YMHandler(AgentNotifier):
    '''Process topup request through YM
    '''
    def __init__(self):
        BaseComponent.__init__(self, 'YM')
        self.c_mutdepo = DBCache(const.MUTATION_PREFIX, config.DEFAULT_EXPIRE,
            const.MUTATION_SQL)
        self.c_mutdepo.setConn(self.dbconn, self.cacheconn)
        self.c_ym_handler = DBCache2(const.YM_HANDLER_PREFIX, config.DEFAULT_EXPIRE,
            const.YM_HANDLER_SQL)
        self.c_ym_handler.setConn(self.dbconn, self.cacheconn)
        self.rrb = {}
        self.prepareCache()
        self.ymgate = '{0}@{1}'.format(config.IMGATE, config.MSG_SERVER)
        self.log = mylogger('YMHandler', 'YMHandler.log')

    def handle(self):
        c = self.dbconn.cursor(MySQLdb.cursors.DictCursor)
        c.execute('''SELECT `transaction_id`,`product_id`,`reg_protocol`,
            `msisdn_destination`,`order`,`deposit`,`sell_price`
            FROM `transaction`
            WHERE `status`={0} and `method`="YM" LIMIT 100
            '''.format(const.TR_AUTHORIZED))
        rows = c.fetchall()
        c.close()
        param = {}
        if not rows:
            return False
        for tr in rows:
            self.notifyTopupInProcess(tr)
            if not self.processYM(tr, param):
                self._notifyAgentFail(tr)
                self._transactionFail(tr['transaction_id'])
                continue
            self._transactionInProgress(tr['transaction_id'], param)
        self.dbconn.commit()
        return True

    def processYM(self, tr, param):
        try:
            nkey = next(self.rrb[tr['product_id']])
            row = self.c_ym_handler.sGet(nkey)
            if not row or not self.c_ym_handler.from_cache:
                raise Exception('{0},{1}'.format(row, self.c_ym_handler.from_cache))
        except Exception, e:
            print e
            self.log.error(e)
            self.prepareCache()
            nkey = next(self.rrb[tr['product_id']])
            row = self.c_ym_handler.sGet(nkey)
            if not row:
                return False
        param['base_price'] = row['base_price']
        param['supplier_name'] = row['supplier_name']
        try:
            order = int(tr['order'])
        except:
            order = 1
        if order <= 1:
            order = '--NONE--'
        ytext = row['format_trx'].format(product_id=row['recv_product_id'],
            msisdn=tr['msisdn_destination'], order=order)
        # ytext = self.cleanTrxFormat(ytext)
        ytext = re.sub('--NONE--', '', ytext)
        msg = '{0},{1},{2}'.format(row['sender_acc'], row['recv_acc'], ytext)
        self.sendMessage(self.ymgate, 'JBYM', msg, commit=False)
        print msg
        return True        
示例#6
0
class TestDeviceAdmin(TestAdminHelper):
    def setUp(self):
        self.bc = BaseComponent()
        self.dbconn = self.bc.dbconn
        self.cacheconn = self.bc.cacheconn
        cursor = self.dbconn.cursor()
        cursor.execute('DELETE FROM `hlr_cache`')
        cursor.execute('DELETE FROM `hlr`')
        cursor.executemany('INSERT INTO `hlr` VALUES (%s,%s,%s,%s,%s,%s)', [
          ('1', '2', 'DKI Jakarta', '100,101,102,103', '2010-10-22 15:29:52', 'bernard'),
          ('2', '1', 'Meong1', '110,111,112', '0000-00-00 00:00:00', 'test'),
          ('3', '1', 'Meong2', '210,211,212', '0000-00-00 00:00:00', 'test'),
          ('4', '3', 'Guk1', '330,331,332', '0000-00-00 00:00:00', 'test'),
        ])
        cursor.execute('DELETE FROM `devices`')
        cursor.executemany('INSERT INTO `devices` VALUES (%s, %s, %s, %s, %s, %s,\
          %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', [
        ('SERVER1.COM10', 'SERVER1', 'COM10', '1', '201001240601026', 'WAVECOM', 'GSM', '1', '0', '', 'MKIOS1', '0', '0', '', '1', '0000-00-00', '2010-11-19 17:40:39', ''),
        ('SERVER1.COM11', 'SERVER1', 'COM11', '1', '201001240600838', 'WAVECOM', 'GSM', '2', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-19 17:22:31', ''),
        ('SERVER1.COM20', 'SERVER1', 'COM20', '1', '201001240600135', 'WAVECOM', 'GSM', '3', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-19 17:28:38', ''),
        ('SERVER1.COM21', 'SERVER1', 'COM21', '1', '201001240600994', 'WAVECOM', 'GSM', '1', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-19 17:28:58', ''),
        ('SERVER1.COM22', 'SERVER1', 'COM22', '1', '201001240601067', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM23', 'SERVER1', 'COM23', '1', '201001240601042', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM24', 'SERVER1', 'COM24', '1', '201001240600671', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM25', 'SERVER1', 'COM25', '1', '351011513521015', 'SIEMENS', 'C55', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM26', 'SERVER1', 'COM26', '1', '010348005275525', 'SIEMENS', 'C55', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM27', 'SERVER1', 'COM27', '1', '03316190103', 'NOKIA', '6235i', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM5', 'SERVER1', 'COM5', '1', '201001240600259', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM6', 'SERVER1', 'COM6', '1', '201001240600762', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM7', 'SERVER1', 'COM7', '1', '201001240600564', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM8', 'SERVER1', 'COM8', '1', '201001240600515', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ('SERVER1.COM9', 'SERVER1', 'COM9', '1', '201001240600655', 'WAVECOM', 'GSM', '0', '0', '', '', '0', '0', '', '1', '0000-00-00', '2010-11-09 21:12:47', ''),
        ])
        self.dbconn.commit()
        self.cacheconn.delete(HLR_CACHEKEY)
        self.h2 = HLRCacheForLB(self.dbconn, self.cacheconn)
        cursor.close()
        self.c_dev = DBCache(const.DEVICES_PREFIX, config.DEFAULT_EXPIRE,
            const.DEVICES_SQL)
        self.c_dev.setConn(self.dbconn, self.cacheconn)
        self.c_dev.sGet('SERVER1.COM10')
        self.c_dev.sGet('SERVER1.COM11')
        self.c_dev.sGet('SERVER1.COM20')
        self.c_dev.sGet('SERVER1.COM21')
        self.c_dev.sGet('SERVER1.COM22')
        self.c_dev.sGet('SERVER1.COM23')
        self.c_dev.sGet('SERVER1.COM24')
        self.c_dev.sGet('SERVER1.COM25')
        self.c_dev.sGet('SERVER1.COM26')
        self.c_dev.sGet('SERVER1.COM27')
        self.c_dev.sGet('SERVER1.COM5')
        self.c_dev.sGet('SERVER1.COM6')
        self.c_dev.sGet('SERVER1.COM7')
        self.c_dev.sGet('SERVER1.COM8')
        self.c_dev.sGet('SERVER1.COM9')
#----------------------
    def runTest(self):
        test_function = [x for x in dir(self) if x[:6] == 'srtest']
        map(lambda x: getattr(self, x)(), sorted(test_function))
#----------------------
    def srtest10_adminHelper(self):
        post_data = {
          'device_id': 'SERVER1.COM10,SERVER1.COM11,SERVER1.COM20,SERVER1.COM21'
        }
        self._callAdminHelper('device_preupdate', post_data)
        cursor = self.dbconn.cursor()
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 1, 'SERVER1.COM10'))
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 1, 'SERVER1.COM11'))
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s, `active`=0 WHERE \
          `device_id`=%s',
          (const.DR_TOPUP, 1, 'SERVER1.COM20'))
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 1, 'SERVER1.COM21'))
        cursor.close()
        self.dbconn.commit()
        self._callAdminHelper('device_postupdate', post_data)
        tmp = self.h2._getHLRCache()
        self.assertEqual(
          ['SERVER1.COM10', 'SERVER1.COM11', 'SERVER1.COM21'],
          sorted(tmp[HLR_DEVICE][1]))
        x = self.c_dev.sGet('SERVER1.COM10')
        self.assertEqual(int(x['function']), const.DR_TOPUP)
        x = self.c_dev.sGet('SERVER1.COM11')
        self.assertEqual(int(x['function']), const.DR_TOPUP)
        x = self.c_dev.sGet('SERVER1.COM21')
        self.assertEqual(int(x['function']), const.DR_TOPUP)
#----------------------
    def srtest20_adminHelper(self):
        post_data = {
          'device_id': 'SERVER1.COM5,SERVER1.COM6,SERVER1.COM7'
        }
        self._callAdminHelper('device_preupdate', post_data)
        cursor = self.dbconn.cursor()
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 2, 'SERVER1.COM5'))
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 2, 'SERVER1.COM6'))
        cursor.execute('UPDATE `devices` set `function`=%s, `hlr_id`=%s where `device_id`=%s',
          (const.DR_TOPUP, 2, 'SERVER1.COM7'))
        cursor.close()
        self.dbconn.commit()
        self._callAdminHelper('device_postupdate', post_data)
        tmp = self.h2._getHLRCache()
        self.assertEqual(
          ['SERVER1.COM5', 'SERVER1.COM6', 'SERVER1.COM7'],
          sorted(tmp[HLR_DEVICE][2]))
#----------------------
    def srtest30_adminHelper(self):
        post_data = {
          'device_id': 'SERVER1.COM20'
        }
        self._callAdminHelper('device_preupdate', post_data)
        cursor = self.dbconn.cursor()
        cursor.execute('UPDATE `devices` set `active`=1, `hlr_id`=%s where `device_id`=%s',
          (3, 'SERVER1.COM20'))
        cursor.close()
        self.dbconn.commit()
        self._callAdminHelper('device_postupdate', post_data)
        tmp = self.h2._getHLRCache()
        self.assertEqual(
          ['SERVER1.COM10', 'SERVER1.COM11', 'SERVER1.COM21'],
          sorted(tmp[HLR_DEVICE][1]))
        self.assertEqual(
          ['SERVER1.COM20',],
          sorted(tmp[HLR_DEVICE][3]))
示例#7
0
文件: TestCore.py 项目: sridwan/meong
class TestCore(TestCoreComponent):
    def setUp(self):
        super(TestCore, self).setUp()
        self.cacheconn.flush_all()
        self._initXMPP(config.LEAFSERVER, config.LEAFSERVER_PASS, 'SERVER1')
        self._initXMPP2('imtest', 'test', 'SERVER1')
        self.setUpTable()
        # TODO: _prConfigHandler
        createProcess(notifyOut, prNotifyIn, prIMDispatch,
            prTopupParser, prAuthorizer, prLoadBalance, prHighPrioritySync,
            prLowPrioritySync)
        HLRCacheForLB(self.dbconn, self.cacheconn).cacheAllTopupDevice()
        time.sleep(8)
        self.c_message = DBCache(const.MESSAGE_PREFIX, config.DEFAULT_EXPIRE,
          const.MESSAGE_SQL)
        self.c_message.setConn(self.dbconn, self.cacheconn)
        showPID()
#----------------------
    def tearDown(self):
        shutdown()
        super(TestCore, self).tearDown()
#----------------------
    def _newSMS(self, cmd, p):
        p = p.format(datetime.now().strftime('%y/%m/%d %H:%M:%S'))
        nin = '{0}@{1}'.format(config.NOTIFYIN, config.MSG_SERVER)
        self._sendCommand(nin, cmd, p)
#----------------------
    def _newIM(self, cmd, p):
        p = p.format(datetime.now().strftime('%y/%m/%d %H:%M:%S'))
        elt = 'elogictopup@yahoo.{0}'.format(config.MSG_SERVER)
        self._sendCommand2(elt, cmd, p)
#----------------------
    def _getMessage(self, msg, tosub={}):
        tmp = self.c_message.sGet(msg)['parse']
        tosub = dict(zip(map(lambda x: '<{0}>'.format(x),tosub.keys()),
          map(str,tosub.values())))
        if tosub == {}:
            return tmp
        return multipleReplace(tosub, tmp)
#----------------------
    def runTest(self):
        test_function = [x for x in dir(self) if x[:6] == 'srtest']
        map(lambda x: getattr(self, x)(), sorted(test_function))
#----------------------
    def srtest10_topup_parser(self):
        # unknown sender
        self._newSMS('FRDV', 'COM51,sms://919191,{0},testing')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, self._getMessage('agent_invalid'))
        # timeout
        self._newSMS('FRDV', 'COM50,sms://08161940700,09/12/15 00:00:00,A10.0812111222.9999')
        r = self._waitForRow('SELECT `command` from `notify_in` where `status`=2 ' \
            'AND `parameters`="COM50,sms://08161940700,09/12/15 00:00:00,A10.0812111222.9999"')
        self.assertEqual(r['command'].upper(), 'UNKN')
        # wrong pin
        self._newSMS('FRDV', 'COM51,sms://08161940700,{0},A10.0812111222.4321')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, self._getMessage('agent_invalid'))
        # wrong product
        self._newSMS('FRDV', 'COM51,sms://08161940700,{0},XXX10.0812111222.9999')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, self._getMessage('prod_not_registered', {'product_id': 'XXX10'}))
        # wrong format
        self._newSMS('FRDV', 'COM50,sms://08161940700,{0},A10.A.0812111222.9999')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, self._getMessage('wrong_req_format'))
        # success, single order
        self._newSMS('FRDV', 'COM50,sms://08161940700,{0},A10.0812111222.9999')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, 'ussd://*677*0812111222*10*122#')
        # get order status
        self._newSMS('FRDV', 'COM51,sms://08161940700,{0},A10.0812111222.9999')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, 'Topup produk A10 untuk 0812111222 DALAM PROSES')
        # multiple order
        self._newSMS('FRDV', 'COM51,sms://08161940700,{0},AX20.0812999888.S10.08128191891.F20.' \
            '02123881891.9999')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, 'Tujuan 0812999888 bukan jaringan Axis.')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, 'Nomor tujuan 08128191891 di luar area kami.')
        m = self._waitForMessage(10)
        _1, _2, m = m.rpartition(',')
        self.assertEqual(m, 'Nomor tujuan 02123881891 di luar area kami.')
#----------------------
    def srtest20_(self):
        pass
#----------------------
    def setUpTable(self):
        self._resetTable('Transaction')
        self._resetTable('Notify_In')
        self._resetTable('Notify_Out')
        self._resetTable('Deposit_Mutation')
        self._resetTable('Deposit_Transfer')
        self._resetTable('Message')
        self._resetTable('Nin_Unknown')
        cursor = self.dbconn.cursor()
        cursor.execute('DELETE FROM `hlr_cache`')
        cursor.execute('DELETE FROM `devices`')
        cursor.execute('''INSERT INTO `devices` (`device_id`, `server_id`, `port`, `active`, `imei`, `brand`, `type`, `operator_id`, `hlr_id`, `msidn_device`, `device_name`, `supplier_id`, `function`, `pin`, `status`, `expired_date`, `last_update`, `last_update_by`) VALUES
            ('SERVER1.COM10', 'SERVER1', 'COM10', 1, '201001240601026', 'WAVECOM', 'GSM', 2, 1, '', 'MKIOS1', 0, 3, '110', 0, '0000-00-00', '2010-11-19 17:40:39', ''),
            ('SERVER1.COM11', 'SERVER1', 'COM11', 1, '201001240600838', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '111', 0, '0000-00-00', '2011-01-12 16:42:41', ''),
            ('SERVER1.COM20', 'SERVER1', 'COM20', 1, '201001240600135', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '120', 0, '0000-00-00', '2011-01-12 16:42:47', ''),
            ('SERVER1.COM21', 'SERVER1', 'COM21', 1, '201001240600994', 'WAVECOM', 'GSM', 2, 1, '', '', 0, 3, '121', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM22', 'SERVER1', 'COM22', 1, '201001240601067', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '122', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM23', 'SERVER1', 'COM23', 1, '201001240601042', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '123', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM24', 'SERVER1', 'COM24', 1, '201001240600671', 'WAVECOM', 'GSM', 1, 2, '', '', 0, 3, '124', 0, '0000-00-00', '2011-01-12 16:43:05', ''),
            ('SERVER1.COM25', 'SERVER1', 'COM25', 1, '351011513521015', 'SIEMENS', 'C55', 1, 2, '', '', 0, 3, '125', 0, '0000-00-00', '2011-01-12 16:43:06', ''),
            ('SERVER1.COM26', 'SERVER1', 'COM26', 1, '010348005275525', 'SIEMENS', 'C55', 1, 3, '', '', 0, 3, '126', 0, '0000-00-00', '2011-01-12 16:43:06', ''),
            ('SERVER1.COM27', 'SERVER1', 'COM27', 1, '03316190103', 'NOKIA', '6235i', 1, 3, '', '', 0, 3, '127', 0, '0000-00-00', '2011-01-12 16:43:07', ''),
            ('SERVER1.COM30', 'SERVER1', 'COM30', 1, '201001240600655', 'WAVECOM', 'CDMA', 7, 7, '', '', 0, 3, '109', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM5', 'SERVER1', 'COM5', 1, '201001240600259', 'WAVECOM', 'GSM', 1, 3, '', '', 0, 3, '105', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM50', 'SERVER1', 'COM50', 1, '', '', '', 0, 0, '', '', 0, 1, '', 0, '0000-00-00', '0000-00-00 00:00:00', ''),
            ('SERVER1.COM51', 'SERVER1', 'COM51', 1, '', '', '', 0, 0, '', '', 0, 1, '', 0, '0000-00-00', '0000-00-00 00:00:00', ''),
            ('SERVER1.COM52', 'SERVER1', 'COM52', 1, '', '', '', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '0000-00-00 00:00:00', ''),
            ('SERVER1.COM53', 'SERVER1', 'COM53', 1, '', '', '', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '0000-00-00 00:00:00', ''),
            ('SERVER1.COM54', 'SERVER1', 'COM54', 1, '', '', '', 0, 0, '', '', 0, 2, '', 0, '0000-00-00', '0000-00-00 00:00:00', ''),
            ('SERVER1.COM6', 'SERVER1', 'COM6', 1, '201001240600762', 'WAVECOM', 'GSM', 1, 3, '', '', 0, 3, '106', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM7', 'SERVER1', 'COM7', 1, '201001240600564', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '107', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM8', 'SERVER1', 'COM8', 1, '201001240600515', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '108', 0, '0000-00-00', '2010-11-09 21:12:47', ''),
            ('SERVER1.COM9', 'SERVER1', 'COM9', 1, '201001240600515', 'WAVECOM', 'GSM', 3, 4, '', '', 0, 3, '109', 0, '0000-00-00', '2010-11-09 21:12:47', '')''')
        cursor.execute('DELETE FROM `hlr`')    
        cursor.execute('''INSERT INTO `hlr` (`hlr_id`, `operator_id`, `location`, `hlr`, `last_update`, `last_update_by`) VALUES
            (1, 2, 'DKI Jakarta', '100,101,102,103', '2010-10-22 15:29:52', 'bernard'),
            (2, 1, 'Meong1', '110,111,112', '0000-00-00 00:00:00', 'test'),
            (3, 1, 'Meong2', '210,211,212', '0000-00-00 00:00:00', 'test'),
            (7, 7, 'Meong2', '021', '0000-00-00 00:00:00', 'test'),
            (4, 3, 'Guk1', '330,331,332', '0000-00-00 00:00:00', 'test')''')    
        cursor.execute('DELETE FROM `operator`')
        cursor.execute('''INSERT INTO `operator` (`operator_id`, `operator_name`, `type`, `prefix`, `stock_check_1`, `stock_check_2`, `sim_balance`, `last_update`, `last_update_by`) VALUES
          (1, 'Telkomsel', 'G', '0812,0813,0852,0853', 'ussd://*776*<pin>#', 'ussd://*676*<pin>#', 'ussd://*888#', '2010-11-17 17:34:44', ''),
          (2, 'Indosat', 'G', '0814,0815,0816,0855,0856,0857,0858', 'data://31.<pin>$', '', 'ussd://*388#', '2010-10-29 18:52:34', ''),
          (3, 'XL', 'G', '0817,0818,0819,0859,0877,0878', 'sms://balance,461', '', 'ussd://*123#', '2010-10-29 18:52:48', ''),
          (4, 'Three', 'G', '0894,0896,0898,0899', 'data://+13.<pin>$', '', '', '2010-10-20 15:08:41', ''),
          (5, 'Axis', 'G', '0831,0832,0833,0838', 'data://13.<pin>$', '', '', '2010-10-20 15:08:36', ''),
          (6, 'Fren', 'G', '0888,0889', '', '', '', '0000-00-00 00:00:00', ''),
          (7, 'Esia', 'C', '4,6,8,9', 'sms:// bal <pin>,898', '', 'sms://talktime,555', '2010-11-17 20:52:29', ''),
          (8, 'Flexi', 'C', '2,3,4,5,6,7,8,9', 'sms://qd#<pin,899', '', '', '2010-10-20 15:10:59', ''),
          (9, 'StarOne', 'C', '3,8', '', '', '', '0000-00-00 00:00:00', ''),
          (10, 'Hepi', 'C', '3,4,5', '', '', '', '0000-00-00 00:00:00', ''),
          (11, 'Smart', 'G', '0881,0882,0883,0884,0885,0886,0887', '', '', '', '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `product`')
        cursor.execute('''INSERT INTO `product` (`product_id`, `product_name`, `operator_id`, `active`, `point`, `operator_product_id_1`, `operator_product_id_2`, `operator_product_id_3`, `operator_product_id_4`, `operator_product_id_5`, `method_1`, `method_1_active`, `method_2`, `method_2_active`, `method_3`, `method_3_active`, `method_4`, `method_4_active`, `method_5`, `method_5_active`, `last_update`, `last_update_by`) VALUES
          ('A10', 'As 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, 'YM', 0, '', 0, '', 0, '2010-07-08 18:48:06', ''),
          ('A5', 'As 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:07', ''),
          ('AP10', 'As 10.000 Promo', 1, 1, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AP5', 'As 5.000 Promo', 1, 0, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AX10', 'Axis 10.000', 5, 1, 1, 'AXIS10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:09', ''),
          ('AX20', 'Axis 20.000', 5, 1, 1, 'AXIS20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('AX50', 'Axis 50.000', 5, 1, 1, 'AXIS50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('BR5', 'Broom 5.000', 2, 1, 1, 'INDOSAT5BROOM', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('E25', 'Esia 25.000', 7, 1, 1, 'ESIA25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('E50', 'Esia 50.000', 7, 1, 1, 'ESIA50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('F10', 'Flexi 10.000', 8, 1, 1, 'FLEXI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:12', ''),
          ('F20', 'Flexi 20.000', 8, 1, 1, 'FLEXI20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:16', ''),
          ('F5', 'Flexi 5.000', 8, 1, 1, 'FLEXI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR10', 'Fren 10.000', 6, 1, 1, 'FREN10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR20', 'Fren 20.000', 6, 1, 1, 'FREN20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:18', ''),
          ('FR25', 'Fren 25.000', 6, 1, 1, 'FREN25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H10', 'Hepi 10.000', 10, 1, 1, 'HEPI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H25', 'Hepi 25.000', 10, 1, 1, 'HEPI25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('H5', 'Hepi 5.000', 10, 1, 1, 'HEPI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('M10', 'Mentari 10.000', 2, 1, 1, 'INDOSAT10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:21', ''),
          ('M5', 'Mentari 5.000', 2, 1, 1, 'INDOSAT5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S10', 'Simpati 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S5', 'Simpati 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:23', ''),
          ('SM10', 'Smart 10.000', 11, 1, 1, 'SMART10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM20', 'Smart 20.000', 11, 1, 1, 'SMART20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM5', 'Smart 5.000', 11, 1, 1, 'SMART5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:25', ''),
          ('SO10', 'StarOne 10.000', 9, 1, 1, 'SO10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO20', 'StarOne 20.000', 9, 1, 1, 'SO20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO5', 'StarOne 5.000', 9, 1, 1, 'SO5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP10', 'Simpati 10.000 Promo', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP5', 'Simpati 5.000 Promo', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:28', ''),
          ('T10', 'Three 10.000', 4, 1, 1, 'THREE10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T20', 'Three 20.000', 4, 1, 1, 'THREE20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T5', 'Three 5.000', 4, 1, 1, 'THREE5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:30', ''),
          ('X10', 'XL 10.000', 3, 1, 1, 'XL10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', ''),
          ('X25', 'XL 25.000', 3, 1, 1, 'XL25', '', '', '', '', '', 0, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('X5', 'XL 5.000', 3, 1, 1, 'XL5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', '')''')
        cursor.execute('DELETE FROM `balance`')
        cursor.execute('''INSERT INTO `balance` (`device_id`, `topup_balance`, `last_update`, `last_update_by`) VALUES
          ('SERVER1.COM7', 100000, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM8', 100000, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM9', 100000, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 100000, '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `unit`')
        cursor.execute('''INSERT INTO `unit` (`device_id`, `operator_product_id`, `balance_unit`, `last_update`, `last_update_by`) VALUES
          ('SERVER1.COM10', 'INDOSAT5', 20, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM10', 'INDOSAT10', 20, '2010-10-25 16:05:59', ''),
          ('SERVER1.COM11', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM11', 'INDOSAT10', 10, '2010-10-27 15:52:40', ''),
          ('SERVER1.COM20', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM20', 'INDOSAT10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM21', 'INDOSAT5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM21', 'INDOSAT10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM22', 'AS10', 20, '2010-10-25 16:05:56', ''),
          ('SERVER1.COM22', 'SIMPATI5', 20, '2010-10-25 16:05:59', ''),
          ('SERVER1.COM23', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM23', 'SIMPATI5', 10, '2010-10-27 15:52:40', ''),
          ('SERVER1.COM24', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM24', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM25', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM25', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM26', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM26', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM27', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM27', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 'ESIA5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM30', 'ESIA10', 20, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM5', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM5', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM6', 'AS10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM6', 'SIMPATI5', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM7', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM7', 'XL10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM8', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM8', 'XL10', 10, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM9', 'XL5', 0, '0000-00-00 00:00:00', ''),
          ('SERVER1.COM9', 'XL10', 10, '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `operator_product`')
        cursor.execute('''INSERT INTO `operator_product` (`operator_product_id`, `balance_flag`, `unit_used`, `operator_id`, `topup_amount_chip`, `topup_parse`, `last_update`, `last_update_by`) VALUES
            ('AS10', 'U', 'AS10', 1, 0, 'ussd://*677*<dest>*10*<pin>#', '2010-10-27 15:41:47', 'admin'),
            ('AS100', 'U', 'AS100', 1, 0, 'ussd://*677*<dest>*100*<pin>#', '2010-10-27 15:41:50', 'admin'),
            ('AS15', 'U', 'AS15', 1, 0, 'ussd://*677*<dest>*15*<pin>#', '2010-10-27 15:41:53', 'admin'),
            ('AS20', 'U', 'AS20', 1, 0, 'ussd://*677*<dest>*20*<pin>#', '2010-10-27 15:41:56', 'admin'),
            ('AS25', 'U', 'AS25', 1, 0, 'ussd://*677*<dest>*25*<pin>#', '2010-10-27 15:41:59', 'admin'),
            ('AS5', 'U', 'AS5', 1, 0, 'ussd://*677*<dest>*5*<pin>#', '2010-10-27 15:42:02', 'admin'),
            ('AS50', 'U', 'AS50', 1, 0, 'ussd://*677*<dest>*50*<pin>#', '2010-10-27 15:42:05', 'admin'),
            ('AXIS10', 'B', '', 5, 10000, 'data://12.<dest>..<pin>$', '2010-10-27 15:47:38', 'admin'),
            ('AXIS100', 'B', '', 5, 100000, 'data://14.<dest>..<pin>$', '2010-10-27 15:47:38', 'admin'),
            ('AXIS20', 'B', '', 5, 20000, 'data://15.20000..<dest>..<pin>$', '2010-10-27 15:47:36', 'admin'),
            ('AXIS25', 'B', '', 5, 25000, 'data://13.<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('AXIS5', 'B', '', 5, 5000, 'data://11.<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('AXIS50', 'B', '', 5, 50000, 'data://15.50000..<dest>..<pin>$', '2010-10-27 15:47:35', 'admin'),
            ('ESIA1', 'U', 'ESIA1', 7, 1000, 'sms://isi <dest> 1 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA10', 'U', 'ESIA10', 7, 10000, 'sms://isi <dest> 10 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA11', 'B', '', 7, 11000, 'sms://isi <dest> 11 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA15', 'B', '', 7, 15000, 'sms://isi <dest> 15 <pin>,898', '2010-10-27 15:47:34', 'admin'),
            ('ESIA20', 'B', '', 7, 20000, 'sms://isi <dest> 20 <pin>,898', '2010-10-27 15:47:33', 'admin'),
            ('ESIA5', 'U', 'ESIA5', 7, 5000, 'sms://isi <dest> 5 <pin>,898', '2010-10-27 15:47:33', 'admin'),
            ('FLEXI10', 'B', '', 8, 10000, 'sms://TOP#<pin>#<dest>#F10,899', '2010-10-27 15:47:32', 'admin'),
            ('FLEXI100', 'B', '', 8, 100000, 'sms://TOP#<pin>#<dest>#100,899', '2010-10-27 15:47:32', 'admin'),
            ('FLEXI20', 'B', '', 8, 20000, 'sms://TOP#<pin>#<dest>#F20,899', '2010-10-27 15:47:31', 'admin'),
            ('FLEXI5', 'B', '', 8, 5000, 'sms://TOP#<pin>#<dest>#F5,899', '2010-10-27 15:47:30', 'admin'),
            ('FLEXI50', 'B', '', 8, 50000, 'sms://TOP#<pin>#<dest>#50,899', '0000-00-00 00:00:00', 'admin'),
            ('INDOSAT10', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.11.<pin>$', '0000-00-00 00:00:00', 'admin'),
            ('INDOSAT100', 'U', 'INDOSAT100', 2, 0, 'data://11.<dest>.51.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT100BROOM', 'U', 'INDOSAT100', 2, 0, 'data://11.9<dest>.51.<pin>$', '2010-10-27 15:43:40', 'admin'),
            ('INDOSAT10BROOM', 'U', 'INDOSAT10', 2, 0, 'data://11.9<dest>.11.<pin>$', '2010-10-27 15:43:35', 'admin'),
            ('INDOSAT10GPRS', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.13.<pin>$', '2010-10-27 15:43:32', 'admin'),
            ('INDOSAT10SMS', 'U', 'INDOSAT10', 2, 0, 'data://11.<dest>.12.<pin>$', '2010-10-27 15:43:29', 'admin'),
            ('INDOSAT25', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.31.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT25BROOM', 'U', 'INDOSAT25', 2, 0, 'data://11.9<dest>.31.<pin>$', '2010-10-27 15:43:26', 'admin'),
            ('INDOSAT25GPRS', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.33.<pin>$', '2010-10-27 15:43:21', 'admin'),
            ('INDOSAT25SMS', 'U', 'INDOSAT25', 2, 0, 'data://11.<dest>.32.<pin>$', '2010-10-27 15:43:17', 'admin'),
            ('INDOSAT5', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.1.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT50', 'U', 'INDOSAT50', 2, 0, 'data://11.<dest>.41.<pin>$', '2010-10-27 15:42:15', 'admin'),
            ('INDOSAT50BROOM', 'U', 'INDOSAT50', 2, 0, 'data://11.9<dest>.41.<pin>$', '2010-10-27 15:43:13', 'admin'),
            ('INDOSAT5BROOM', 'U', 'INDOSAT5', 2, 0, 'data://11.9<dest>.6.5000.1.<pin>$', '2010-10-27 15:42:42', 'admin'),
            ('INDOSAT5GPRS', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.3.<pin>$', '2010-10-27 15:42:37', 'admin'),
            ('INDOSAT5SMS', 'U', 'INDOSAT5', 2, 0, 'data://11.<dest>.6.5000.2.<pin>$', '2010-10-27 15:42:33', 'admin'),
            ('SIMPATI10', 'U', 'SIMPATI10', 1, 0, 'ussd://*777*<dest>*10*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI100', 'U', 'SIMPATI100', 1, 0, 'ussd://*777*<dest>*50*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI20', 'U', 'SIMPATI20', 1, 0, 'ussd://*777*<dest>*20*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI5', 'U', 'SIMPATI5', 1, 0, 'ussd://*777*<dest>*5*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('SIMPATI50', 'U', 'SIMPATI50', 1, 0, 'ussd://*777*<dest>*25*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('THREE1', 'B', '', 4, 1000, 'data://+11.<dest>..<dest>..1000..1000..<pin>$', '2010-10-27 15:48:32', 'admin'),
            ('THREE10', 'B', '', 4, 10000, 'data://+11.<dest>..<dest>..10000..10000..<pin>$', '2010-10-27 15:48:33', 'admin'),
            ('THREE100', 'B', '', 4, 100000, 'data://+11.<dest>..<dest>..100000..100000..<pin>$', '2010-10-27 15:48:33', 'admin'),
            ('THREE2', 'B', '', 4, 2000, 'data://+11.<dest>..<dest>..2000..2000..<pin>$', '2010-10-27 15:48:34', 'admin'),
            ('THREE20', 'B', '', 4, 20000, 'data://+11.<dest>..<dest>..20000..20000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE3', 'B', '', 4, 3000, 'data://+11.<dest>..<dest>..3000..3000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE30', 'B', '', 4, 30000, 'data://+11.<dest>..<dest>..30000..30000..<pin>$', '2010-10-27 15:48:37', 'admin'),
            ('THREE4', 'B', '', 4, 4000, 'data://+11.<dest>..<dest>..4000..4000..<pin>$', '2010-10-27 15:48:38', 'admin'),
            ('THREE5', 'B', '', 4, 5000, 'data://+11.<dest>..<dest>..5000..5000..<pin>$', '2010-10-27 15:48:39', 'admin'),
            ('THREE50', 'B', '', 4, 50000, 'data://+11.<dest>..<dest>..50000..50000..<pin>$', '2010-10-27 15:48:39', 'admin'),
            ('XL1', 'U', 'XL1', 3, 0, 'USSD://*101*1000*00*<dest>*<pin>#', '2010-10-27 17:59:06', 'admin'),
            ('XL10', 'U', 'XL10', 3, 0, 'USSD://*101*10000*00*<dest>*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('XL100', 'B', '', 3, 100000, 'USSD://*101*100000*00*<dest>*<pin>#', '2010-10-27 15:47:18', 'admin'),
            ('XL25', 'B', '', 3, 25000, 'USSD://*101*25000*00*<dest>*<pin>#', '2010-10-27 15:47:15', 'admin'),
            ('XL5', 'U', 'XL5', 3, 0, 'USSD://*101*5000*00*<dest>*<pin>#', '2010-10-27 15:42:15', 'admin'),
            ('XL50', 'B', '', 3, 50000, 'USSD://*101*50000*00*<dest>*<pin>#', '2010-10-27 15:47:12', 'admin')''')
        cursor.execute('DELETE FROM `agent`')
        cursor.execute('''INSERT INTO `agent` (`agent_id`, `active`, `agent_name`, `agent_address`, `agent_type`, `pin`, `upline_id`, `markup`, `markup_upline`, `set_price`, `register_date`, `last_activity_date`, `last_update`, `last_update_by`) VALUES
            ('00001', 1, 'Bernard Martian', 'Test', 1, '9999', '', 100, 0, 'Test', '2010-11-09 18:24:44', '2010-11-09 18:24:51', '2010-11-24 00:50:12', ''),
            ('00002', 1, 'Stephanus Ridwan', 'PM', 1, '8888', '00001', 0, 100, 'Test', '2010-11-09 18:24:44', '2010-11-09 18:24:51', '2011-01-12 21:20:01', ''),
            ('00003', 1, 'Dewi Karyana', 'Depok', 1, '0891', '00002', 0, 100, 'Test', '2010-11-09 18:24:51', '2010-11-09 18:24:51', '2011-01-12 21:20:22', '')''')
        cursor.execute('DELETE FROM `agent_price`')
        cursor.execute('''INSERT INTO `agent_price` (`agent_id`, `product_id`, `sell_price`, `markup_upline`, `date_time`, `status`, `last_update`, `last_update_by`) VALUES
            ('00001', 'A10', 10150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'A5', 5150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'AX50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'E25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'E50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'F5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'FR25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'H5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'M10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'M5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'S10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'S5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SM5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SO5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'SP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'T5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'X10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00001', 'X5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
            ('00002', 'A10', 10250, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'A5', 5250, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AP10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AP5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'AX50', 50200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'E25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'E50', 50200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'F5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'FR25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H25', 25200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'H5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'M10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'M5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'S10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'S5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SM5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SO5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SP10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'SP5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T20', 20200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'T5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'X10', 10200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00002', 'X5', 5200, 100, NULL, 1, '2011-01-12 21:20:01', ''),
            ('00003', 'A10', 10350, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'A5', 5350, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AP10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AP5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'AX50', 50300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'E25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'E50', 50300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'F5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'FR25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H25', 25300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'H5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'M10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'M5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'S10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'S5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SM5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SO5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SP10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'SP5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T20', 20300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'T5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'X10', 10300, 100, NULL, 1, '2011-01-12 21:20:22', ''),
            ('00003', 'X5', 5300, 100, NULL, 1, '2011-01-12 21:20:22', '')''')
        cursor.execute('''INSERT INTO `deposit_mutation` (`deposit_mutation_id`, `timestamp`, `agent_id`, `mutation`, `type`, `deposit_balance`, `comment`) VALUES
            (1, '2011-01-12 22:00:51', '00001', 100000, 'C', 100000, 'Initial'),
            (2, '2011-01-12 22:01:29', '00002', 150000, 'C', 150000, 'Initial'),
            (3, '2011-01-12 22:01:51', '00003', 120000, 'C', 120000, 'Initial')''')
        cursor.execute('''INSERT INTO `message` (`name`, `description`, `parse`) VALUES
          ('agent_invalid', 'Invalid Agent', 'Agen tidak terdaftar atau PIN salah.'),
          ('agent_not_enough_balance', 'Not Enough Balance', 'Topup <product_id> gagal. Saldo tidak mencukupi. Sisa saldo <balance>.'),
          ('agent_not_frontline', 'Agent is not your downline', 'Agen <agent_id> bukan downline langsung.'),
          ('agent_not_reg', 'Agent not registered', 'Agent <agent_id> tidak terdaftar.'),
          ('amount_not_number', 'Amount transfer is not numeric', '<amount> bukan angka.'),
          ('amount_zero', 'Amount can not be zero', 'Jumlah transfer tidak boleh 0 (nol).'),
          ('change_frontlinemarkup_success', 'Markup Agent', 'Rubah markup agen <agent_id> BERHASIL. Markup baru: <markup>.'),
          ('change_globalmarkup_success', 'Markup Global', 'Rubah markup seluruh downline BERHASIL. Markup baru: <markup>.'),
          ('change_pin', 'Change PIN', 'Ganti PIN sukses. Pin baru adalah <pin>.'),
          ('deposit_level', 'Deposit', 'Deposit: <deposit>.'),
          ('hlr_not_supported', 'HLR Not Supported', 'Nomor tujuan <dest> di luar area kami.'),
          ('markup_is_zero', 'Markup can not be zero', 'Markup harus lebih besar dari 0.'),
          ('markup_not_number', 'Markup is not numeric', 'Markup <markup> bukan angka.'),
          ('num_op_dont_match', 'Operator not match with destination', 'Tujuan <dest> bukan jaringan <operator>.'),
          ('out_of_stock', 'Closed Product', 'Produk <product_id> tidak tersedia.'),
          ('product_price', 'Product Price', 'Harga <product_id>: <price>.'),
          ('prod_not_registered', 'Product not registered', 'Produk <product_id> tidak tersedia.'),
          ('register_new_agent', 'New Agent', 'Agen "<name>" memiliki kode agen: <agent_id>. PIN awal: 1234.'),
          ('topup_fail', 'Top up Fail', 'Topup tidak berhasil, <reason>.'),
          ('transaction_status', 'Transaction Status', 'Topup produk <product_id> untuk <dest> <status>'),
          ('transaction_successful', 'Transaction Report', 'Transaksi <product_id> untuk <dest> BERHASIL. Ref:<ref> saldo <balance>'),
          ('transfer_agent_not_enough_bal', 'Not Enough Balance', 'Saldo agen tidak cukup untuk transfer. Saldo agen <agent_id> <balance>.'),
          ('transfer_fail', 'Transfer Fail', 'Transfer untuk saat ini tidak dapat dilakukan. Cobalah beberapa saat lagi.'),
          ('transfer_not_enough_balance', 'Transfer Not Enough Balance', 'Saldo tidak mencukupi untuk transfer. Saldo anda <balance>.'),
          ('transfer_over_revoke', 'Transfer Over Revoke', 'Tidak bisa mengambil lebih banyak dari transfer harian. Sisa transfer hari ini <transfer>.'),
          ('transfer_status', 'Transfer Status', 'Transfer deposit agen <agent_id>, order ke-<order> sebesar <amount> BERHASIL.'),
          ('unknown_command', 'Unknown Command', 'Perintah tidak dikenal.'),
          ('wrong_req_format', 'Wrong Format', 'Format topup request tidak dikenal.')''')
        cursor.execute('DELETE FROM `regprotocol`')
        cursor.execute('''INSERT INTO `regprotocol` (`reg_protocol`, `agent_id`) VALUES
            ('sms://08161940700', '00001'),
            ('sms://02123881811', '00002'),
            ('ym://sridwan981', '00002'),
            ('sms://02196818889', '00003')''')
        cursor.execute('DELETE FROM `message`')
        cursor.execute('''INSERT INTO `message` (`name`, `description`, `parse`) VALUES
            ('agent_invalid', 'Invalid Agent', 'Agen tidak terdaftar atau PIN salah.'),
            ('agent_not_enough_balance', 'Not Enough Balance', 'Topup <product_id> gagal. Saldo tidak mencukupi. Sisa saldo <balance>.'),
            ('agent_not_frontline', 'Agent is not your downline', 'Agen <agent_id> bukan downline langsung.'),
            ('agent_not_reg', 'Agent not registered', 'Agent <agent_id> tidak terdaftar.'),
            ('amount_not_number', 'Amount transfer is not numeric', '<amount> bukan angka.'),
            ('amount_zero', 'Amount can not be zero', 'Jumlah transfer tidak boleh 0 (nol).'),
            ('change_frontlinemarkup_success', 'Markup Agent', 'Rubah markup agen <agent_id> BERHASIL. Markup baru: <markup>.'),
            ('change_globalmarkup_success', 'Markup Global', 'Rubah markup seluruh downline BERHASIL. Markup baru: <markup>.'),
            ('change_pin', 'Change PIN', 'Ganti PIN sukses. Pin baru adalah <pin>.'),
            ('deposit_level', 'Deposit', 'Deposit: <deposit>.'),
            ('hlr_not_supported', 'HLR Not Supported', 'Nomor tujuan <dest> di luar area kami.'),
            ('markup_is_zero', 'Markup can not be zero', 'Markup harus lebih besar dari 0.'),
            ('markup_not_number', 'Markup is not numeric', 'Markup <markup> bukan angka.'),
            ('num_op_dont_match', 'Operator not match with destination', 'Tujuan <dest> bukan jaringan <operator>.'),
            ('out_of_stock', 'Closed Product', 'Produk <product_id> tidak tersedia.'),
            ('product_price', 'Product Price', 'Harga <product_id>: <price>.'),
            ('prod_not_registered', 'Product not registered', 'Produk <product_id> tidak tersedia.'),
            ('register_new_agent', 'New Agent', 'Agen "<name>" memiliki kode agen: <agent_id>. PIN awal: 1234.'),
            ('topup_fail', 'Top up Fail', 'Topup tidak berhasil, <reason>.'),
            ('transaction_status', 'Transaction Status', 'Topup produk <product_id> untuk <dest> <status>'),
            ('transaction_successful', 'Transaction Report', 'Transaksi <product_id> untuk <dest> BERHASIL. Ref:<ref> saldo <balance>'),
            ('transfer_agent_not_enough_bal', 'Not Enough Balance', 'Saldo agen tidak cukup untuk transfer. Saldo agen <agent_id> <balance>.'),
            ('transfer_fail', 'Transfer Fail', 'Transfer untuk saat ini tidak dapat dilakukan. Cobalah beberapa saat lagi.'),
            ('transfer_not_enough_balance', 'Transfer Not Enough Balance', 'Saldo tidak mencukupi untuk transfer. Saldo anda <balance>.'),
            ('transfer_over_revoke', 'Transfer Over Revoke', 'Tidak bisa mengambil lebih banyak dari transfer harian. Sisa transfer hari ini <transfer>.'),
            ('transfer_status', 'Transfer Status', 'Transfer deposit agen <agent_id>, order ke-<order> sebesar <amount> BERHASIL.'),
            ('unknown_command', 'Unknown Command', 'Perintah tidak dikenal.'),
            ('wrong_req_format', 'Wrong Format', 'Format topup request tidak dikenal.')''')
        self.dbconn.commit()
        cursor.close()
示例#8
0
class TestAuthorizer(TestCoreComponent):
    def setUp(self):
        super(TestAuthorizer, self).setUp()
        self.cacheconn.flush_all()
        cursor = self.dbconn.cursor()
        self._resetTable('Transaction')
        self._resetTable('Notify_Out')
        self._resetTable('Deposit_Mutation')
        cursor.execute('DELETE FROM `operator`')
        cursor.execute('''INSERT INTO `operator` (`operator_id`, `operator_name`, `type`, `prefix`, `stock_check_1`, `stock_check_2`, `sim_balance`, `last_update`, `last_update_by`) VALUES
          (1, 'Telkomsel', 'G', '0812,0813,0852,0853', 'ussd://*776*<pin>#', 'ussd://*676*<pin>#', 'ussd://*888#', '2010-11-17 17:34:44', ''),
          (2, 'Indosat', 'G', '0814,0815,0816,0855,0856,0857,0858', 'data://31.<pin>$', '', 'ussd://*388#', '2010-10-29 18:52:34', ''),
          (3, 'XL', 'G', '0817,0818,0819,0859,0877,0878', 'sms://balance,461', '', 'ussd://*123#', '2010-10-29 18:52:48', ''),
          (4, 'Three', 'G', '0894,0896,0898,0899', 'data://+13.<pin>$', '', '', '2010-10-20 15:08:41', ''),
          (5, 'Axis', 'G', '0831,0832,0833,0838', 'data://13.<pin>$', '', '', '2010-10-20 15:08:36', ''),
          (6, 'Fren', 'G', '0888,0889', '', '', '', '0000-00-00 00:00:00', ''),
          (7, 'Esia', 'C', '4,6,8,9', 'sms:// bal <pin>,898', '', 'sms://talktime,555', '2010-11-17 20:52:29', ''),
          (8, 'Flexi', 'C', '2,3,4,5,6,7,8,9', 'sms://qd#<pin,899', '', '', '2010-10-20 15:10:59', ''),
          (9, 'StarOne', 'C', '3,8', '', '', '', '0000-00-00 00:00:00', ''),
          (10, 'Hepi', 'C', '3,4,5', '', '', '', '0000-00-00 00:00:00', ''),
          (11, 'Smart', 'G', '0881,0882,0883,0884,0885,0886,0887', '', '', '', '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `agent_price`')
        cursor.execute('''INSERT INTO `agent_price` (`agent_id`, `product_id`,
          `sell_price`, `markup_upline`, `date_time`, `status`, `last_update`,
          `last_update_by`) VALUES
          ('00001', 'A10', 10150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'A5', 5150, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'AP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'AP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'AX10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'AX20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'AX50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'E25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'E50', 50100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'F10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'F20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'F5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'FR10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'FR20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'FR25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'H10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'H25', 25100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'H5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'M10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'M5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'S10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'S5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SM10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SM20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SM5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SO10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SO20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SO5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SP10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'SP5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'T10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'T20', 20100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'T5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'X10', 10100, 0, NULL, 1, '0000-00-00 00:00:00', ''),
          ('00001', 'X5', 5100, 0, NULL, 1, '0000-00-00 00:00:00', '')''')
        cursor.execute('DELETE FROM `product`')
        cursor.execute('''INSERT INTO `product` (`product_id`, `product_name`, `operator_id`, `active`, `point`, `operator_product_id_1`, `operator_product_id_2`, `operator_product_id_3`, `operator_product_id_4`, `operator_product_id_5`, `method_1`, `method_1_active`, `method_2`, `method_2_active`, `method_3`, `method_3_active`, `method_4`, `method_4_active`, `method_5`, `method_5_active`, `last_update`, `last_update_by`) VALUES
          ('A10', 'As 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, 'YM', 0, '', 0, '', 0, '2010-07-08 18:48:06', ''),
          ('A5', 'As 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:07', ''),
          ('AP10', 'As 10.000 Promo', 1, 1, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AP5', 'As 5.000 Promo', 1, 0, 1, 'AS5', 'SIMPATI5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:08', ''),
          ('AX10', 'Axis 10.000', 5, 1, 1, 'AXIS10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:09', ''),
          ('AX20', 'Axis 20.000', 5, 1, 1, 'AXIS20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('AX50', 'Axis 50.000', 5, 1, 1, 'AXIS50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:10', ''),
          ('BR5', 'Broom 5.000', 2, 1, 1, 'INDOSAT5BROOM', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('E25', 'Esia 25.000', 7, 1, 1, 'ESIA25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('E50', 'Esia 50.000', 7, 1, 1, 'ESIA50', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:11', ''),
          ('F10', 'Flexi 10.000', 8, 1, 1, 'FLEXI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:12', ''),
          ('F20', 'Flexi 20.000', 8, 1, 1, 'FLEXI20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:16', ''),
          ('F5', 'Flexi 5.000', 8, 1, 1, 'FLEXI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR10', 'Fren 10.000', 6, 1, 1, 'FREN10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:17', ''),
          ('FR20', 'Fren 20.000', 6, 1, 1, 'FREN20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:18', ''),
          ('FR25', 'Fren 25.000', 6, 1, 1, 'FREN25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H10', 'Hepi 10.000', 10, 1, 1, 'HEPI10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:19', ''),
          ('H25', 'Hepi 25.000', 10, 1, 1, 'HEPI25', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('H5', 'Hepi 5.000', 10, 1, 1, 'HEPI5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:20', ''),
          ('M10', 'Mentari 10.000', 2, 1, 1, 'MENTARI10', 'IM10', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:21', ''),
          ('M5', 'Mentari 5.000', 2, 1, 1, 'MENTARI5', 'IM5', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S10', 'Simpati 10.000', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:22', ''),
          ('S5', 'Simpati 5.000', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:23', ''),
          ('SM10', 'Smart 10.000', 11, 1, 1, 'SMART10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM20', 'Smart 20.000', 11, 1, 1, 'SMART20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:24', ''),
          ('SM5', 'Smart 5.000', 11, 1, 1, 'SMART5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:25', ''),
          ('SO10', 'StarOne 10.000', 9, 1, 1, 'SO10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO20', 'StarOne 20.000', 9, 1, 1, 'SO20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:26', ''),
          ('SO5', 'StarOne 5.000', 9, 1, 1, 'SO5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP10', 'Simpati 10.000 Promo', 1, 1, 1, 'SIMPATI10', 'AS10', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:27', ''),
          ('SP5', 'Simpati 5.000 Promo', 1, 1, 1, 'SIMPATI5', 'AS5', '', '', '', 'CH', 1, 'H2', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:28', ''),
          ('T10', 'Three 10.000', 4, 1, 1, 'THREE10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T20', 'Three 20.000', 4, 1, 1, 'THREE20', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:29', ''),
          ('T5', 'Three 5.000', 4, 1, 1, 'THREE5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:30', ''),
          ('X10', 'XL 10.000', 3, 1, 1, 'XL10', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', ''),
          ('X25', 'XL 25.000', 3, 1, 1, 'XL25', '', '', '', '', '', 0, '', 0, '', 0, '', 0, '', 0, '0000-00-00 00:00:00', ''),
          ('X5', 'XL 5.000', 3, 1, 1, 'XL5', '', '', '', '', 'CH', 1, '', 0, '', 0, '', 0, '', 0, '2010-07-08 18:48:31', '')''')
        cursor.close()
        self.dbconn.commit()
        self._createProcess(_prAuthorizer)
        self.ids = []
        self.c_message = DBCache(const.MESSAGE_PREFIX, config.DEFAULT_EXPIRE,
          const.MESSAGE_SQL)
        self.c_message.setConn(self.dbconn, self.cacheconn)
        self.idgen = range(50)
        self.deposit = DepositMutation(1, self.dbconn, self.cacheconn)
        self.deposit.credit('00001', 25000, 'setup credit', True)
#----------------------
    def runTest(self):
        test_function = [x for x in dir(self) if x[:6] == 'srtest']
        map(lambda x: getattr(self, x)(), sorted(test_function))
#----------------------
    def srtest10_authorized(self):  # TR_AUTHORIZED
        self.newRequest(('1', '00001', 'sms://08161940700', 'A10', '08128191891', 1, 0, 1))
        t = self._waitForRow('SELECT `status` from `transaction` WHERE '
          '`transaction_id`="1" and `status`={0}'.format(const.TR_AUTHORIZED))
        self.assertEqual(t, {'status': const.TR_AUTHORIZED})
        t = self._waitForRow('SELECT `mutation`,`type`,`deposit_balance` FROM '
          '`deposit_mutation` where `deposit_balance`=14850 and `agent_id`="00001"')
        self.assertEqual(t, {'mutation': 10150, 'type': "D", 'deposit_balance': 14850})
#----------------------
    def srtest20_wrong_number(self):  # TR_DENIED_WRONG_NUMBER
        self.newRequest(('2', '00001', 'sms://08161940700', 'A10', '08168191891', 1, 0, 1))
        t = self._waitForRow('SELECT `status` from `transaction` WHERE '
          '`transaction_id`="2" and `status`={0}'.format(const.TR_DENIED_WRONG_NUMBER))
        self.assertEqual(t, {'status': const.TR_DENIED_WRONG_NUMBER})
        t = self._waitForRow('SELECT `command` from `notify_out` where `parameters` '
          'LIKE "sms://08161940700,% 08168191891 %"')
        self.assertEqual(t, {'command': 'SMSG'})
#----------------------
    def srtest30_denied_product(self):  # TR_DENIED_PRODUCT
        self.newRequest(('3', '00001', 'sms://08161940700', 'XXX10', '08168191891', 1, 0, 2))
        self.newRequest(('4', '00001', 'sms://08161940700', 'AP5', '08168191891', 1, 0, 1))
        t = self._waitForRow('SELECT `status` from `transaction` WHERE '
          '`transaction_id`="3" and `status`={0}'.format(const.TR_DENIED_PRODUCT))
        self.assertEqual(t, {'status': const.TR_DENIED_PRODUCT})
        t = self._waitForRow('SELECT `command` from `notify_out` where `parameters` '
          'LIKE "sms://08161940700,% XXX10 %"')
        self.assertEqual(t, {'command': 'SMSG'})
        t = self._waitForRow('SELECT `status` from `transaction` WHERE '
          '`transaction_id`="4" and `status`={0}'.format(const.TR_DENIED_PRODUCT))
        self.assertEqual(t, {'status': const.TR_DENIED_PRODUCT})
        t = self._waitForRow('SELECT `command` from `notify_out` where `parameters` '
          'LIKE "sms://08161940700,% AP5 %"')
        self.assertEqual(t, {'command': 'SMSG'})
        t = self._waitForRow('SELECT COUNT(*) FROM `deposit_mutation`')
        self.assertEqual(t, {'COUNT(*)': 3})
#----------------------
    def srtest40_denied_balance(self):  # TR_DENIED_BALANCE
        self.newRequest(('5', '00001', 'sms://08161940700', 'AX50', '0838000111', 1, 0, 5))
        t = self._waitForRow('SELECT `status` from `transaction` WHERE '
          '`transaction_id`="5" and `status`={0}'.format(const.TR_DENIED_BALANCE))
        self.assertEqual(t, {'status': const.TR_DENIED_BALANCE})
        t = self._waitForRow('SELECT `command` from `notify_out` where `parameters` '
          'LIKE "sms://08161940700,% AX50 %"')
        self.assertEqual(t, {'command': 'SMSG'})
#----------------------
    def newRequest(self, p):
        cursor = self.dbconn.cursor()
        cursor.execute('INSERT INTO `transaction` (`transaction_id`,`agent_id`,'
          '`reg_protocol`,`product_id`,`msisdn_destination`,`order`,`status`,`operator_id`) '
          'VALUES (%s,%s,%s,%s,%s,%s,%s,%s)', p)
        cursor.close()
        self.dbconn.commit()
#----------------------
    def getMessage(self, msg, tosub={}):
        tmp = self.c_message.sGet(msg)['parse']
        tosub = dict(zip(map(lambda x: '<{0}>'.format(x),tosub.keys()),
          map(str,tosub.values())))
        if tosub == {}:
            return tmp
        return multipleReplace(tosub, tmp)