Exemple #1
0
    def run_testproject(self, http):
        logger.info('正在获取测试项目[id:%s, name:%s]对应对应的测试计划名称列表' %
                    (self.project_id, self.name))
        testplans_name_list = []
        testplans = mytestlink.getProjectTestPlans(self.project_id)
        for testplan in testplans:
            testplans_name_list.append(testplan['name'])
        logger.info('成功获取项目测试计划名称列表[list=%s]' % testplans_name_list)

        for testplan in testplans_name_list:
            testplan_info = mytestlink.getTestPlanByName(self.name, testplan)
            testplan_name = testplan_info[0]['name']
            testplan_id = int(testplan_info[0]['id'])
            active_status = int(testplan_info[0]['active'])
            notes = other_tools.conver_date_from_testlink(
                testplan_info[0]['notes'])
            testplan_obj = TestPlan(testplan_name, testplan_id, active_status,
                                    notes, self.name)

            logger.info('正在执行项目测试计划[project:%s,testplan:%s]' %
                        (self.name, testplan))
            testplan_obj.run_testplan(http)
                myhttp = MyHttp(protocol, host, port)
                logger.info('正在执行测试项目[id:%s, project:%s]' %
                            (project_id, project_name))
                project_obj.run_testproject(myhttp)
    elif 2 == run_mode:
        logger.info('按计划运行测试')
        project_of_plans = run_mode_conf.get_project_of_testplans()
        testplans_name_list = run_mode_conf.get_testplans()
        testplans_name_list = eval(testplans_name_list)
        logger.info('已获取配置的项目名称[name:%s]及对应的测试计划名称列表[list=%s]' %
                    (project_of_plans, testplans_name_list))

        for testplan in testplans_name_list:
            # 构造测试计划对象
            try:
                testplan_info = mytestlink.getTestPlanByName(
                    project_of_plans, testplan)
            except Exception as e:
                logger.error('测试计划[project:%s,testplan:%s]获取失败,暂时无法执行:%s' %
                             (project_of_plans, testplan, e))
                continue

            testplan_name = testplan_info[0]['name']
            testplan_id = int(testplan_info[0]['id'])
            active_status = int(testplan_info[0]['active'])
            notes = other_tools.conver_date_from_testlink(
                testplan_info[0]['notes'])
            testplan_obj = TestPlan(testplan_name, testplan_id, active_status,
                                    notes, project_of_plans)

            logger.info('正在读取测试计划[project:%s,testplan:%s]的协议,host,端口配置...' %
                        (project_of_plans, testplan))