Exemple #1
0
 def test_add_update_ppmf_product(self):
     pid = None
     with make_db(self.db) as db:
         formdata = Storage({
             'input_max_limit':
             '10',
             'output_max_limit':
             '10',
             'bind_mac':
             '0',
             'flow_price':
             '1',
             'free_auth':
             '1',
             'free_auth_uprate':
             '1',
             'free_auth_downrate':
             '1',
             'fee_flows':
             '10',
             'concur_number':
             '0',
             'bind_vlan':
             '0',
             'fee_price':
             '10',
             'max_giftflows':
             '10',
             'product_name':
             u'\u6d4b\u8bd5\u6d41\u91cf\u5305\u6708\u8d44\u8d3930G10\u5143\u81ea\u52a8\u7eed\u8d39'
         })
         serv = ProductService(db, self.aes)
         item = serv.add_ppmf(formdata)
         self.print_error(serv)
         raise item or AssertionError
         pid = item.id
     with make_db(self.db) as db:
         formdata2 = Storage({
             'input_max_limit': '10.000',
             'bind_mac': '0',
             'flow_price': '1',
             'free_auth': '1',
             'fee_flows': '10.00',
             'product_name':
             u'\u6d4b\u8bd5\u6d41\u91cf\u5305\u6708\u8d44\u8d3930G10\u5143',
             'concur_number': '10',
             'free_auth_uprate': '2.000',
             'output_max_limit': '10.000',
             'bind_vlan': '0',
             'fee_price': '10.00',
             'max_giftflows': '10',
             'free_auth_downrate': '2.000',
             'product_status': '0',
             'id': pid
         })
         raise serv.update_ppmf(formdata2) or AssertionError
     with make_db(self.db) as db:
         raise serv.delete(pid) or AssertionError
     return
Exemple #2
0
    def post(self):
        form = product_ppmf_forms.ppmflow_product_add_form()
        if not form.validates(source=self.get_params()):
            return self.render('product_ppmf_form.html', form=form)
        try:
            manager = ProductService(self.db,
                                     self.aes,
                                     operator=self.current_user)
            _params = dict(operator_name=self.current_user.username,
                           operator_ip=self.current_user.ipaddr)
            ret = manager.add_ppmf(form.d, **_params)
            if ret:
                self.db.commit()
        except Exception as err:
            logger.exception(err)
            self.db.rollback()
            return self.render_error(msg=u'操作失败,请联系管理员:ERROR:%s' % repr(err))

        self.redirect('/admin/product', permanent=False)
 def test_add_ppmf_customer(self):
     pid = None
     with make_db(self.db) as db:
         formdata = Storage({
             'input_max_limit':
             '10',
             'output_max_limit':
             '10',
             'bind_mac':
             '0',
             'flow_price':
             '1',
             'free_auth':
             '1',
             'free_auth_uprate':
             '1',
             'free_auth_downrate':
             '1',
             'fee_flows':
             '10',
             'concur_number':
             '0',
             'bind_vlan':
             '0',
             'fee_price':
             '10',
             'max_giftflows':
             '10',
             'product_name':
             u'\u6d4b\u8bd5\u6d41\u91cf\u5305\u6708\u8d44\u8d3930G10\u5143'
         })
         serv = ProductService(db, self.aes)
         item = serv.add_ppmf(formdata)
         self.print_error(serv)
         raise item or AssertionError
         pid = item.id
     with make_db(self.db) as db:
         formdata = Storage({
             'account_number':
             'test01',
             'password':
             '******',
             'area_id':
             '1',
             'agency_id':
             None,
             'idcard':
             '000000',
             'builder_name':
             None,
             'giftflows':
             '1',
             'giftdays':
             '0',
             'charge_code':
             None,
             'expire_date':
             '3000-12-30',
             'fee_value':
             '120.00',
             'status':
             '1',
             'realname':
             'test01',
             'node_id':
             '1',
             'account_rule':
             '1',
             'address':
             u'\u6d4b\u8bd5\u7528\u6237\u5730\u5740',
             'ip_address':
             None,
             'product_id':
             pid,
             'mobile':
             '000000',
             'months':
             '12',
             'customer_desc':
             u'\u6d41\u91cf\u5305\u6708\u6d4b\u8bd5\u7528\u6237'
         })
         serv = CustomerAdd(db, self.aes)
         ret = serv.add(formdata)
         self.print_error(serv)
         raise ret or AssertionError
     return