Пример #1
0
 def replace_data(self, data):
     config_d2 = ConfigData(data)
     request_key = config_d2.get_depend_request_key()
     run_data = config_d2.get_run_data()
     respone_key_list = self.get_data_for_key(data)
     request_key_list = request_key.split(";")
     if not isinstance(run_data, dict):
         run_data = json.loads(run_data)
     for i in range(len(request_key_list)):
         run_data[request_key_list[i]] = respone_key_list[i]
     return json.dumps(run_data)
Пример #2
0
 def get_data_for_key(self, data):
     res = self.run_depend_case(data)
     config_d2 = ConfigData(data)
     response_key = config_d2.get_depend_reponse_key()
     response_key_list = response_key.split(";")
     key_list = []
     for key in response_key_list:
         json_exe = parse(key)
         madle = json_exe.find(res)
         key_list.append([match.value for match in madle][0])
     is_connect = config_d2.get_is_connect()
     if is_connect:
         return [is_connect.join(key_list)]
     else:
         return key_list
Пример #3
0
 def run_main(self, data):
     self.data = data
     self.handle_data()
     header = self.handle_h.handle_h(self.header_info)
     if self.is_run:
         if self.depend_case_id:
             h = HandleDepend()
             self.run_data = h.replace_data(data)
         if self.run_data:
             self.run_data = handle(self.run_data)
         if header[1]:
             #发送带cookie
             res = self.run_m.send_request(method=self.method,
                                           url=self.url,
                                           data=self.run_data,
                                           header=header[0],
                                           cookie=header[1])
         else:
             res = self.run_m.send_request(method=self.method,
                                           url=self.url,
                                           data=self.run_data,
                                           header=header[0])
         #写入cookie
         if header[2]:
             self.handle_h.write_cookie(res)
         compare = Compare()
         config_d1 = ConfigData(self.data)
         print(self.expect, res.text)
         if compare.comp(self.expect, res.text):
             print("pass")
             config_d1.write_result("pass", self.case_id)
         else:
             print("fail")
             config_d1.write_result("fail", self.case_id)
Пример #4
0
 def get_depend_data(self, data):
     depend_data = self.get_data_from_db(data)
     config_d = ConfigData(depend_data)
     self.url = config_d.get_url()
     self.method = config_d.get_method()
     self.header_info = config_d.get_header_info()
     self.run_data = config_d.get_run_data()
     # self.depend_case_id = config_d.get_depend_case_id()
     # self.depend_response_key = config_d.get_depend_reponse_key()
     # self.depend_request_key = config_d.get_depend_request_key()
     self.is_connect = config_d.get_is_connect()
Пример #5
0
from page.register_page import RegisterPage
from base.browser_engine import BrowserEngine
import unittest
import ddt
from config.config_data import ConfigData
import os, time
from log.log_record import LogRecord
import multiprocessing

c = ConfigData()
data = c.get_data_for_excel()


@ddt.ddt
class Test(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = BrowserEngine(parames).start_browser()
        cls.rp = RegisterPage(cls.driver)
        cls.log = LogRecord()
        cls.logger = cls.log.log_record()

    @ddt.data(*data)
    @ddt.unpack
    def test(self, *args):
        self.rp.register(*args)
        self.expect = args[4]
        self.expect_method = args[5]

    def tearDown(self):
        for method_name, error in self._outcome.errors:
Пример #6
0
 def handle_data(self):
     config_d = ConfigData(self.data)
     self.case_id = config_d.get_case_id()
     self.case_name = config_d.get_case_name()
     self.url = config_d.get_url()
     self.method = config_d.get_method()
     self.header_info = config_d.get_header_info()
     self.run_data = config_d.get_run_data()
     self.is_run = config_d.get_is_run()
     self.depend_case_id = config_d.get_depend_case_id()
     self.depend_response_key = config_d.get_depend_reponse_key()
     self.depend_request_key = config_d.get_depend_request_key()
     self.is_connect = config_d.get_is_connect()
     self.is_connect_db = config_d.get_is_connect_db()
     self.is_mock = config_d.get_is_mock()
     self.expect = config_d.get_expect()
Пример #7
0
 def get_data_from_db(self, data):
     config_d1 = ConfigData(data)
     case_id = config_d1.get_depend_case_id()
     sql = "SELECT * FROM `case` where caseid='" + case_id + "';"
     depend_data = self.op_db.get_one(sql)
     return depend_data