コード例 #1
0
 def get(self):
     customer = Customer(self)
     data_list = yield gen.Task(customer.get_ips)
     if self.get_argument('a', 'list') == 'add':
         self.render('addcustomer.html', data_list=data_list)
     else:
         self.render('customer.html', data_list=data_list)
コード例 #2
0
    def post(self):

        action = self.get_argument('action', '')
        if action == 'delete':
            name = self.get_argument('name', '')
            ip = self.get_argument('ip', '')
            customer = Customer(self)
            yield gen.Task(customer.delete_ip, name, ip)

        else:
            name = self.get_argument('name', '')
            ip_list = self.get_argument('ips').split()
            customer = Customer(self)
            yield gen.Task(customer.add_ips, name, ip_list)

        self.redirect('/customer')
コード例 #3
0
 def delete(self):
     name = self.get_argument('name', '')
     if not name:
         self.write(u'名称不能为空')
         self.finish()
     else:
         customer = Customer(self)
         yield gen.Task(customer.delete_customer, name)
         self.redirect('/customer')
コード例 #4
0
 def put(self):
     name = self.get_argument('name', '')
     new_name = self.get_argument('new_name', '')
     if (not new_name) or (not name):
         self.write(u'名称不能为空')
         self.finish()
     else:
         customer = Customer(self)
         yield gen.Task(customer.rename_customer, name, new_name)
         self.redirect('/customer')
コード例 #5
0
 def create(self):
     name = self.get_argument('name', '')
     if not name:
         self.write(u'名称不能为空')
         self.finish()
     else:
         customer = Customer(self)
         res = yield gen.Task(customer.add_customer, name)
         if res:
             self.redirect('/customer?a=add')
         else:
             self.redirect('/customer?a=add')
コード例 #6
0
ファイル: customer_test.py プロジェクト: Sequoia617/dixiaoran
class CustomerTest(unittest.TestCase):
    add_customer_conf = Utility.get_json('..\\conf\\testinfo.conf')[1]
    add_customer_info = Utility.trans_tuple(add_customer_conf)
    query_customer_conf = Utility.get_json('..\\conf\\testinfo.conf')[2]
    query_customer_info = Utility.trans_tuple(query_customer_conf)
    edit_customer_conf = Utility.get_json('..\\conf\\testinfo.conf')[3]
    edit_customer_info = Utility.trans_tuple(edit_customer_conf)

    @classmethod
    def setUpClass(cls):
        pass

    @classmethod
    def tearDownClass(cls):
        pass

    def setUp(self):
        from lib.customer import Customer
        from tools.service import Service
        self.min = Customer(Service.get_session())

    def tearDown(self):
        pass

    @parameterized.expand(add_customer_info)
    def test_add_customer(self, url, method, cname, cphone, csex, cdate,
                          ckids, ccloth, expect):
        add_customer_data = {'URL': url, 'METHOD': method,
                             "ADDMINUTESDATA": {"customername": cname, "customerphone": cphone, "childsex": csex
                                 , "childdate": cdate, "creditkids": ckids, "creditcloth": ccloth},
                             'EXPECT': expect}
        add_customer_resp = self.min.do_add_customer(add_customer_data['URL'], add_customer_data['METHOD']
                                                     , add_customer_data['ADDMINUTESDATA'])
        result = add_customer_resp.text
        print(result)
        if result == 'add-successful':
            actual = 'add success'
        elif result == 'already-added':
            actual = 'already-added'
        elif 'Error' in result:
            actual = 'error'
        self.assertEqual(actual, add_customer_data['EXPECT'])

    @parameterized.expand(query_customer_info)
    def test_query_customer(self, url, method, cphone, pag, expect):
        query_customer_data = {'URL': url, 'METHOD': method,
                               "ADDMINUTESDATA": {"customerphone": cphone, "page": pag},
                               'EXPECT': expect}
        query_customer_resp = self.min.do_query_customer(query_customer_data['URL'], query_customer_data['METHOD']
                                                         , query_customer_data['ADDMINUTESDATA'])
        result = query_customer_resp.json()
        result1 = query_customer_resp.text
        print(result1)
        if result == []:
            acutal = 'query faild'
        else:
            if 'childsex' in result[0]:
                acutal = 'query success'

        self.assertEqual(acutal, query_customer_data['EXPECT'])

    @parameterized.expand(edit_customer_info)
    def test_edit_customer(self, url, method, cid, cname, cphone, csex, cdate,
                           ckids, ccloth, expect):
        edit_customer_data = {'URL': url, 'METHOD': method,
                              "ADDMINUTESDATA": {"customerid": cid, "customerphone": cphone, "customername": cname
                                  , "childsex": csex, "childdate": cdate, "creditkids": ckids
                                  , "creditcloth": ccloth},
                              'EXPECT': expect}
        edit_customer_resp = self.min.do_edit_customer(edit_customer_data['URL'], edit_customer_data['METHOD']
                                                       , edit_customer_data['ADDMINUTESDATA'])
        result = edit_customer_resp.text
        print(result)
        if result == 'edit-successful':
            actual = 'edit success'
        elif 'Error' in result:
            actual = 'edit faild'
        self.assertEqual(actual, edit_customer_data['EXPECT'])
コード例 #7
0
ファイル: customer_test.py プロジェクト: Sequoia617/dixiaoran
 def setUp(self):
     from lib.customer import Customer
     from tools.service import Service
     self.min = Customer(Service.get_session())
コード例 #8
0
 def get(self):
     name = self.get_argument('name', '')
     customer = Customer(self)
     ip_list = yield gen.Task(customer.get_ips, name)
     self.render('ips.html', ip_list=ip_list)
コード例 #9
0
 def get(self, name):
     customer = Customer(self)
     data_list = yield gen.Task(customer.get_ips, name)
     self.render('customer.html', data_list=data_list)
コード例 #10
0
ファイル: fn.py プロジェクト: heeki/lambda_oci_py
            body = json.loads(base64.b64decode(event["body"]))
            customer.set_given_name(body["given_name"])
            customer.set_family_name(body["family_name"])
            customer.set_birthdate(body["birthdate"])
            customer.set_email(body["email"])
            customer.set_phone_number(body["phone_number"])
            customer.set_phone_number_verified(body["phone_number_verified"])
            response = customer.create()
            print(response)
        else:
            response = {
                "HTTPStatusCode": 500,
                "ResponseBody": {
                    "ErrorMessage": "Request body is missing",
                    "ErrorType": "InputError"
                }
            }
        status = response["HTTPStatusCode"]
        payload = str(customer) if status == 200 else json.dumps(
            response["ResponseBody"])
        output = build_response(status, payload)

    print(output)
    return output


# initialization, mapping
ddb = boto3.client("dynamodb")
table = os.environ["TABLE"]
customer = Customer(ddb, table)
コード例 #11
0
 def _c(id, demand=0, r_time=0, dd=0, s_time=0):
     return Customer([id, 0, 0, demand, r_time, dd, s_time])