コード例 #1
0
 def __init__(self, testlinkAddr, key):
     """
     初始化类,需要传递testlink的地址,及testlink的key
     :param testlinkAddr: testlink地址,类似http://testlink.wanqian.store/lib/api/xmlrpc/v1/xmlrpc.php
     :param key:testlink的key
     """
     self.tlc = testlink.TestlinkAPIClient(testlinkAddr, key)
コード例 #2
0
 def __init__(self, build_tag):
     self.tlc = testlink.TestlinkAPIClient(config.testlink_url,
                                           config.testlink_devkey,
                                           encoding="utf-8")
     self.jenkins = jenkins.Jenkins(config.jenkins_url, config.jenkins_user,
                                    config.jenkins_password)
     self.fsp_version, branch = self.get_build_number(build_tag)
     print self.fsp_version, branch
     self.testProject = "流式服务"
コード例 #3
0
 def __init__(self, server_url=None, devkey=None):
     server_url = server_url or os.environ.get('TESTLINK_URL')
     devkey = devkey or os.environ.get('TESTLINK_DEVKEY')
     if not all([server_url, devkey]):
         raise testlink.TestLinkError(
             "Please, set TESTLINK_URL and TESTLINK_DEVKEY environment variables"
         )
     self.client: testlink.TestlinkAPIClient = testlink.TestlinkAPIClient(
         server_url, devkey)
コード例 #4
0
ファイル: TestlinkTool.py プロジェクト: Hanlen520/sosotest-1
    def __init__(self,
                 url="http://192.168.0.102/testlink/lib/api/xmlrpc.php",
                 key="d65fcff4ad29e42c8e931a3ed0c314dd"):
        self.url = url
        self.key = key
        self.tlc = testlink.TestlinkAPIClient(url, key)

        self.manual = 1  # 手动
        self.automation = 2  # 自动
コード例 #5
0
    def __init__(self):
        tlk_helper = TestLinkHelper()
        url = "http://192.168.199.13:81/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
        key = "68194d618ccb4ce674f3935d73bf77ac"

        try:
            self.testlink = testlink.TestlinkAPIClient(url, key)  # 连接TestLink
        except Exception as e:
            logger.error('连接testlink失败:%s' % e)
            exit()
コード例 #6
0
    def setup(self):
        self.logger.info("test setup")
        #获取testlink连接
        self.tlc = testlink.TestlinkAPIClient(self.testlink_url, self.testlink_key)
        #获取testplane name
        tp = self.tlc.getTestPlanByName(self.project_name, self.testPlanName)
        #获取第一个testplan 的id
        self.tpid = tp[0]["id"]
        # 获取性能测试集的id
        testsuite_id =""
        top_suites = self.tlc.getFirstLevelTestSuitesForTestProject(self.project_id)
        for suite in top_suites:
            if suite["name"] == u"性能测试":
                testsuite_id = suite["id"]
        #获取该用例的版本信息,最大的那个
        versions=list()
        ids = self.tlc.getTestCasesForTestPlan(self.tpid)
        self.logger.info("ids is %s " % ids)

        for te in ids.keys():
            for te_v in ids[te]:
                if te_v['full_external_id'] == self.testid:
                    versions.append(te_v["version"])
        maxversion= int(max(versions))
        self.logger.info("version is %s " % maxversion)
        #获取最新的build name
        self.build_names = self.tlc.getBuildsForTestPlan(self.tpid)
        self.logger.info("build names  is %s " % self.build_names)
        build_list = [ float(i["name"]) for i in self.build_names ]
        self.logger.info("build_list  is %s " % build_list)
        self.build_name= max(build_list)
        self.logger.info("build name  is %s " % self.build_name)




        # 获取该用例的测试关键字
        self.concurrency = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "concurrency", "simple")["value"]
        self.logger.info("concurrency is %s " % self.concurrency)
        self.round = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "round", "simple")["value"]
        self.logger.info("round is %s " % self.round)
        self.ip = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "ip", "simple")["value"]
        self.logger.info("ip is %s " % self.ip)
        self.port = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "port", "simple")["value"]
        self.logger.info("port is %s " % self.port)
        self.url = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "url", "simple")["value"]
        self.logger.info("url is %s " % self.url)
        self.layout = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "layout", "simple")["value"]
        self.logger.info("layout is %s " % self.layout)
        self.appFunction = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "x-acs-app-function", "simple")["value"]
        self.logger.info(" x-acs-app-function is %s " % self.appFunction)
        self.files = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "files","simple")["value"]
        self.logger.info(" files is %s " % self.files)
        self.host = self.tlc.getTestCaseCustomFieldDesignValue(self.testid, maxversion, self.project_id, "host","simple")["value"]
        self.logger.info(" host is %s " % self.host)
コード例 #7
0
 def connect_testlink(self, TESTLINK_API_PYTHON_SERVER_URL,
                      TESTLINK_API_PYTHON_DEVKEY):
     '''
     :param TESTLINK_API_PYTHON_SERVER_URL: testlink的接口地址 如:http://IP:PORT/lib/api/xmlrpc/v1/xmlrpc.php
     :param TESTLINK_API_PYTHON_DEVKEY: 2e9685efd7d2589b50987f00dc9d10d7 接口秘钥
     :return:
     '''
     try:
         self.tls = testlink.TestlinkAPIClient(
             TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY)
     except Exception as e:
         print("连接Testlink失败:%s" % e)
コード例 #8
0
def init_testlink():
    """Test link initialization"""
    if not TLINK.enabled:
        return
    # check ignore_unverified_cer option
    context = None
    if int(TLINK.conf.get('ignore_unverified_cer')):
        context = ssl._create_unverified_context()

    # connect to test link
    TLINK.rpc = testlink.TestlinkAPIClient(server_url=TLINK.conf['xmlrpc_url'],
                                           devKey=TLINK.conf['api_key'],
                                           context=context)

    # assert test project exists
    _test_project = TLINK.rpc.getTestProjectByName(TLINK.conf['project'])
    if not _test_project:
        TLINK.disable_or_exit(
            'Invalid tl_project name. Unable to find project')
        return

    # type convert from list for older testlink instances
    _test_project = _test_project[0] \
        if isinstance(_test_project, list) else _test_project

    # get project id and prefix
    TLINK.project_id = _test_project['id']
    TLINK.project_prefix = _test_project['prefix']

    # create test plan if required
    plan_name = [
        tp for tp in TLINK.rpc.getProjectTestPlans(TLINK.project_id)
        if tp['name'] == TLINK.conf['test_plan']
    ]
    if not plan_name:
        # pylint: disable=E1121
        TLINK.rpc.createTestPlan(TLINK.conf['test_plan'],
                                 TLINK.conf['project'])
        plan_name = [
            tp for tp in TLINK.rpc.getProjectTestPlans(TLINK.project_id)
            if tp['name'] == TLINK.conf['test_plan']
        ]
    TLINK.test_plan_id = plan_name[0]['id']

    TLINK.test_build_id = None
    TLINK.test_platform = None

    TLINK.tc_pattern = re.compile(r'%s\d+' % TLINK.conf['pytest_tc_prefix'],
                                  re.I)
コード例 #9
0
    def export_test_case(self):

        url = 'http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php'
        key = '2370ebb0b852cfa4f4b557c0d7001220'
        tlc = testlink.TestlinkAPIClient(url, key)

        tc_lis = []
        project_id = tlc.getProjectIDByName(self.project_name)

        for data in tlc.getFirstLevelTestSuitesForTestProject(project_id):
            id1 = data['id']
            name1 = data['name']
            for data in tlc.getTestCasesForTestSuite(id1, True, 'full'):
                name = data["name"]
                external_id = data["external_id"]
                importance = data["importance"]
                execution_type = data["execution_type"]
                author = data["author_id"]

                for i in range(len(data["steps"])):
                    tc_dic = {}
                    steps = data["steps"][i]["actions"]
                    except_result = data["steps"][i]["expected_results"]
                    step_str = str(steps)
                    except_result_str = str(except_result).replace(
                        '<p>', "").replace('</p>', "").replace('\n', "")
                    method = re.search(
                        '(([\u8bf7\u6c42\u7c7b\u578b]+:).+?(?=</p))',
                        step_str).group(1).replace('请求类型:', "")
                    url = re.search(
                        '(([\u8bf7\u6c42\u5730\u5740]+:).+?(?=</p))',
                        step_str).group(1).replace('请求地址:', "")
                    data = re.search(
                        '(([\u8bf7\u6c42\u53c2\u6570]+:).+?(?=</p))',
                        step_str).group(1).replace('请求参数:',
                                                   "").replace('&#39;', "'")
                    tc_dic['Model'] = name1
                    tc_dic['Case'] = name
                    tc_dic['Num'] = external_id
                    tc_dic['Importance'] = self.format_importance(importance)
                    tc_dic['Method'] = method
                    tc_dic['Url'] = url
                    tc_dic['Data'] = data
                    tc_dic['Expect'] = except_result_str
                    tc_lis.append(tc_dic)
        return tc_lis
コード例 #10
0
 def reportTLRusult(self, devkey, testplanid, buildid, testcaseid, status,
                    notes):
     """
     将执行结果上报至testlink \n
     :param testplanid: 计划ID \n
     :param buildid: 版本ID \n
     :param testcaseexternalid: 用例ID \n
     :param status: 执行结果 :p 通过   f 失败   b 锁定  \n
     :param notes: 执行结果备注 \n
     :return:
     """
     timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     server = testlink.TestlinkAPIClient(self.url, devkey)
     server.reportTCResult(testplanid=int(testplanid),
                           buildid=int(buildid),
                           testcaseexternalid=testcaseid,
                           status=status,
                           notes=notes,
                           timestamp=timestamp)
コード例 #11
0
def init_testlink():
    """Test link initialization"""
    if not TLINK.enabled:
        return
    # connect to test link
    TLINK.rpc = testlink.TestlinkAPIClient(server_url=TLINK.conf['xmlrpc_url'], devKey=TLINK.conf['api_key'])

    # assert test project exists
    _test_project = TLINK.rpc.getTestProjectByName(TLINK.conf['project'])
    if not _test_project:
        TLINK.disable_or_exit('Invalid tl_project name. Unable to find project')
        return

    # type convert from list for older testlink instances
    _test_project = _test_project[0] if isinstance(_test_project, list) else _test_project

    # get project id and prefix
    TLINK.project_id = _test_project['id']
    TLINK.project_prefix = _test_project['prefix']

    # list of test plans
    plans = {plan['id']: plan for plan in TLINK.rpc.getProjectTestPlans(TLINK.project_id)}

    # create test plan if required
    plan_name = [tp for tp in TLINK.rpc.getProjectTestPlans(TLINK.project_id) if tp['name'] == TLINK.conf['test_plan']]
    if not plan_name:
        TLINK.rpc.createTestPlan(TLINK.conf['test_plan'], TLINK.conf['project'])
        plan_name = [tp for tp in TLINK.rpc.getProjectTestPlans(TLINK.project_id) if
                     tp['name'] == TLINK.conf['test_plan']]
    TLINK.test_plan_id = plan_name[0]['id']

    # create test build if required
    TLINK.test_build = [tb for tb in TLINK.rpc.getBuildsForTestPlan(TLINK.test_plan_id)
                        if tb['name'] == TLINK.conf['build_name']]
    if not TLINK.test_build:
        TLINK.rpc.createBuild(int(TLINK.test_plan_id), TLINK.conf['build_name'],
                              'Automated test. Created by mf_testlink plugin.')
        TLINK.test_build = [tb for tb in TLINK.rpc.getBuildsForTestPlan(TLINK.test_plan_id)
                            if tb['name'] == TLINK.conf['build_name']]
    TLINK.test_build_id = TLINK.test_build[0]['id']
    print(TLINK.test_build_id)
コード例 #12
0
ファイル: countTestPlan.py プロジェクト: lisen886/TestTool
import testlink, json, sys
import configparser
conf = configparser.ConfigParser()
conf.read("extend.ini")
key = conf.get('testlink', 'key')
url = conf.get('testlink', 'url')
try:
    tlc = testlink.TestlinkAPIClient(url, key)
except:
    print("TestLink 服务不可用")


# tlc.listProjects()
def get_project():
    projects = []
    projectsInfo = tlc.getProjects()
    for project in projectsInfo:
        projects.append({
            "projectName": project['name'],
            "projectID": project['id']
        })
    return projects


def get_projectID(projectName):
    projects = get_project()
    for project in projects:
        if projectName == project["projectName"]:
            return project["projectID"]
    else:
        return False
コード例 #13
0
ファイル: run_test_module.py プロジェクト: stooczu/DPP_lab12
    # run the testsuite
    result = runner.run(suite)

    # print json output
    # pprint(result.jsonify())

    TESTLINK_API_PYTHON_SERVER_URL = "http://192.168.43.122/lib/api/xmlrpc/v1/xmlrpc.php"
    TESTLINK_API_PYTHON_DEVKEY = "425a0eba97d42c8005a07c7613e359c1"

    # tls = testlink.TestLinkHelper( TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY).connect(testlink.TestlinkAPIClient)

    tlh = testlink.TestLinkHelper(TESTLINK_API_PYTHON_SERVER_URL,
                                  TESTLINK_API_PYTHON_DEVKEY)
    tls = testlink.TestlinkAPIClient(tlh._server_url,
                                     tlh._devkey,
                                     verbose=False)

    print("\n\nProjects count: " + str(tls.countProjects()) + "\n\n")

    tc_info = tls.getTestCase(None, testcaseexternalid='1-1')
    # print("\n\n" + str(tc_info) + "\n\n")

    tc_info = tls.getProjectTestPlans('1')
    # print("\n\n" + str(tc_info) + "\n\n")
    # tls.reportTCResult(4, 2, 'SampleBuild', 'f', 'some notes', user='******', platformid='1')
    date = str(datetime.datetime.now())
    date.replace("-", "/")
    date = date[:-7]
    steps_result = result.jsonify()['TestSimple']['ok']
    steps_result2 = sorted(steps_result.keys())
コード例 #14
0
ファイル: test.py プロジェクト: dovelx/python
# -*- coding:utf-8 -*-
import testlink
from testlink import TestLinkHelper, TestlinkAPIClient

manual = 1  # 手动
automation = 2  # 自动

# 连接test link
url = "http://127.0.0.1/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
key = "2cc20c4892d7e31bf2774663c3e067cf"  # 我这个key是错误的key
tlc = testlink.TestlinkAPIClient(url,devKey=key)
#获取testlink上的信息
def get_information_test_project():
    print("Number of Projects      in TestLink: %s " % tlc.countProjects())
    print("Number of Platforms  (in TestPlans): %s " % tlc.countPlatforms())
    print("Number of Builds                   : %s " % tlc.countBuilds())
    print("Number of TestPlans                : %s " % tlc.countTestPlans())
    print("Number of TestSuites               : %s " % tlc.countTestSuites())
    print("Number of TestCases (in TestSuites): %s " % tlc.countTestCasesTS())
    print("Number of TestCases (in TestPlans) : %s " % tlc.countTestCasesTP())
    tlc.listProjects()
#获取 test suite
def get_test_suite():
    projects = tlc.getProjects()
    top_suites = tlc.getFirstLevelTestSuitesForTestProject(projects[0]["id"])
    for suite in top_suites:
        print (suite["id"], suite["name"])
#创建测试用例集
def create_test_suite(project_id, test_suite_name, test_suite_describe, father_id):
    if father_id == "":
        tlc.createTestSuite(project_id, test_suite_name, test_suite_describe)
コード例 #15
0
# coding=utf-8
# 2019.01.08
import testlink
import time
import re

url = "http://192.168.20.94:8083/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
tester_key = {"admin": "68f26f458e8b1d537043f76d78f815d9"}
tlc = testlink.TestlinkAPIClient(url, tester_key["admin"])

project_name = '嵌入式固件'
test_plan_name = '固件网络配置'
first_menu = ['盒子', '国内立扫公版用例']


# 读取用例执行结果
def test_result():
    with open('testlinkNote', 'r', encoding='UTF-8', errors='ignore') as f:
        content = f.read()
        f.close()

    return content


# 更新测试结果
def to_execute_cases():

    # 获取本次要测试的项目
    projects = tlc.getProjects()
    target_project = [
        project for project in projects if project['name'] == project_name
コード例 #16
0
    def __init__(self):

        url = myglobal.testlink_config.getValue('TESTLINK', 'url')
        key = myglobal.testlink_config.getValue('TESTLINK', 'key')

        self.tlc = testlink.TestlinkAPIClient(url, key)
コード例 #17
0
    def __init__(self):

        self.url = testlink_config.getValue('TESTLINK', 'url')
        self.key = testlink_config.getValue('TESTLINK', 'key')

        self.tlc = testlink.TestlinkAPIClient(self.url, self.key)
コード例 #18
0
ファイル: cli_autoscripts.py プロジェクト: symlib/clitest
    zach = "1e2a6e7af20e5c274174ff68e2ba63a2"
    hulda = 'bc473e34c21e2fe7161dc8374274744b'
    robot = "31c13726fc2bae727aa02faaaa574892"
    if lname == "jacky":
        new_adminjl_key = jacky
    elif lname == "zach":
        new_adminjl_key = zach
    elif lname == "hulda":
        new_adminjl_key = hulda
    else:
        new_adminjl_key = robot

    # # new_testlink="http://192.168.252.175/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
    #new_ip_testlink = "http://10.10.10.3/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
    new_ip_testlink = "http://192.168.252.104/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
    tls = testlink.TestlinkAPIClient(new_ip_testlink, new_adminjl_key)

    # test case notes
    Notes = 'testlink.notes'
    exectype = {"g": -1, "a": 1, "c": -2}
    execinputtype = raw_input(
        "please input what test cases you are going to execute, g --- GUI, a ---- API, c ---- CLI"
    )
    #execinputtype = "a"
    if execinputtype == "c":
        c, ssh = ssh_conn()

    # print tls.whatArgs('getTestCase')

    # build names to be updated before run this script
    # TC_build_name_MAC='4.02.0000.01'
コード例 #19
0
 def __init__(self, url=None, devkey=None):
     if url: self.testlink_url = url
     if devkey: self.testlink_devkey = devkey
     self.mylink = testlink.TestlinkAPIClient(self.testlink_url,
                                              self.testlink_devkey)
コード例 #20
0
def getTestLinkObject(testLinkURL, testLinkDEVKEY):
    """establishes connection with TestLink and returns thye object that interacts with TestLink"""
    testLinkObject = testlink.TestlinkAPIClient(testLinkURL, testLinkDEVKEY)
    return testLinkObject
コード例 #21
0
 def __init__(self):
     url = setting.TESTLINK_CONFIG["url"]
     key = setting.TESTLINK_CONFIG["key"]
     self.tlc = testlink.TestlinkAPIClient(url, key)
コード例 #22
0
 def __init__(self, url, dev_key):
     self.url = url
     self.key = dev_key
     if self._tl_obj is None:
         self._tl_obj = testlink.TestlinkAPIClient(self.url, self.key)
コード例 #23
0
def main():

    # create logging file handler
    logger = logging.getLogger("json_to_testlink")
    logger.setLevel(logging.INFO)
    fh = logging.FileHandler("json_to_testlink.log")
    sh = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fh.setFormatter(formatter)
    sh.setFormatter(formatter)
    logger.addHandler(fh)
    logger.addHandler(sh)

    logger.info("Test reporter started!")

    settings_path = 'json_to_testlink_settings.ini'

    # creating settings.ini if not exists, reading all settings
    if os.path.exists(settings_path):
        testlink_server_ip = config.get_setting(settings_path, 'Settings',
                                                'testlink_server_ip')
        testlink_server_port = config.get_setting(settings_path, 'Settings',
                                                  'testlink_server_port')
        testlink_api_url = config.get_setting(settings_path, 'Settings',
                                              'testlink_api_url')
        dev_key = config.get_setting(settings_path, 'Settings', 'dev_key')
        testlink_user = config.get_setting(settings_path, 'Settings',
                                           'testlink_user')
        testlink_password = config.get_setting(settings_path, 'Settings',
                                               'testlink_password')
        testlink_project_name = config.get_setting(settings_path, 'Settings',
                                                   'testlink_project_name')
        testlink_test_project_prefix = config.get_setting(
            settings_path, 'Settings', 'testlink_test_project_prefix')
        testlink_testsuite_id = config.get_setting(settings_path, 'Settings',
                                                   'testlink_testsuite_id')
        testlink_testplan_id = config.get_setting(settings_path, 'Settings',
                                                  'testlink_testplan_id')
        testlink_build_id = config.get_setting(settings_path, 'Settings',
                                               'testlink_build_id')
        testlink_info = config.get_setting(settings_path, 'Settings',
                                           'testlink_info')
        logger.info(testlink_info)
    else:
        config.create_config(settings_path)
        testlink_server_ip = config.get_setting(settings_path, 'Settings',
                                                'testlink_server_ip')
        testlink_server_port = config.get_setting(settings_path, 'Settings',
                                                  'testlink_server_port')
        testlink_api_url = config.get_setting(settings_path, 'Settings',
                                              'testlink_api_url')
        dev_key = config.get_setting(settings_path, 'Settings', 'dev_key')
        testlink_user = config.get_setting(settings_path, 'Settings',
                                           'testlink_user')
        testlink_password = config.get_setting(settings_path, 'Settings',
                                               'testlink_password')
        testlink_project_name = config.get_setting(settings_path, 'Settings',
                                                   'testlink_project_name')
        testlink_test_project_prefix = config.get_setting(
            settings_path, 'Settings', 'testlink_test_project_prefix')
        testlink_testsuite_id = config.get_setting(settings_path, 'Settings',
                                                   'testlink_testsuite_id')
        testlink_testplan_id = config.get_setting(settings_path, 'Settings',
                                                  'testlink_testplan_id')
        testlink_build_id = config.get_setting(settings_path, 'Settings',
                                               'testlink_build_id')
        testlink_info = config.get_setting(settings_path, 'Settings',
                                           'testlink_info')
        logger.info(testlink_info)

    # command line arguments parser settings
    parser = argparse.ArgumentParser(
        description='Report builder requires relative json report path for '
        'report generation.')
    parser.add_argument("json_report_path",
                        metavar='1',
                        type=str,
                        help='json report file name or file path')
    args = parser.parse_args()
    logger.debug(str(parser.parse_args()))
    json_report_path = parser.parse_args().json_report_path

    testlink_connection_url = "http://{}{}{}".format(testlink_server_ip,
                                                     testlink_server_port,
                                                     testlink_api_url)
    logger.debug("Testlink_connection_string = " + testlink_connection_url)

    tls = testlink.TestlinkAPIClient(testlink_connection_url, dev_key)
    logger.debug("Check api connection: ")
    logger.debug(print(tls.about()))

    logger.info("Start json parsing")
    json_test_data = json_parse.json_read(json_report_path)

    # internal variables
    awn_test_suite = json_test_data['testResults']
    step_info = []
    report_step_info = []
    test_case_names = []
    execution_type = 2  # for manual set 1, for automated set 2
    test_case_version = 1
    # test_case_status = 'b'
    this_file_dirname = os.path.dirname(__file__)
    logger.debug(this_file_dirname)
    log_path = os.path.join(this_file_dirname, 'report_log.csv')
    logger.debug(log_path)

    testlink_testproject_id = tls.getProjectIDByName(testlink_project_name)
    logger.debug("Test_project_id: " + str(testlink_testproject_id))
    logger.debug("Get_Project_TCases")
    response = tls.getTestCasesForTestSuite(testsuiteid=testlink_testsuite_id)
    for tc in range(len(response)):
        test_case_names.append(response[tc]['name'])
    logger.debug("Project TCases: " + str(test_case_names))

    for test in range(len(awn_test_suite)):
        test_case = json_test_data['testResults'][test]['stepResults']
        logger.debug(json_parse.read_test_case_name(json_test_data, test))
        for step in range(len(test_case)):
            # print("Test step: ")
            logger.debug(
                json_parse.read_test_case_step_actions(json_test_data, test,
                                                       step))
            step_info.append({
                'step_number':
                step + 1,
                'actions':
                json_parse.read_test_case_step_actions(json_test_data, test,
                                                       step),
                'expected_results':
                json_parse.read_test_case_step_expected_results(
                    json_test_data, test, step),
                'execution_type':
                execution_type
            })
            report_step_info.append({
                'step_number':
                step + 1,
                'result':
                json_parse.read_test_case_step_status(json_test_data, test,
                                                      step),
                'notes':
                json_parse.read_test_case_step_execution_notes(
                    json_test_data, test, step)
            })

            logger.debug(step_info)
            logger.debug(report_step_info)

        if json_parse.read_test_case_name(json_test_data,
                                          test) in test_case_names:
            test_case_id = tls.getTestCaseIDByName(
                json_parse.read_test_case_name(json_test_data, test))[0]['id']
            new_result = tls.reportTCResult(
                testcaseid=test_case_id,
                testplanid=testlink_testplan_id,
                buildid=testlink_build_id,
                status=json_parse.read_test_case_status(json_test_data, test),
                execduration=json_parse.read_test_case_exec(
                    json_test_data, test),
                timestamp=json_parse.read_test_case_start_time(
                    json_test_data, test),
                steps=report_step_info)
            logger.info("Test case report created: " + str(response))

            log_info = json_parse.read_test_case_logs(json_test_data, test)
            logger.debug(log_info)
            json_parse.csv_write(log_info, log_path)

            new_result_id = new_result[0]['id']
            try:
                new_attachment = tls.uploadExecutionAttachment(
                    log_path, new_result_id, "logfile",
                    'Test case logfile for a AWN Execution run')
                logger.info("Test case attachment upload done :" +
                            str(new_attachment))
            except TLResponseError:
                pass

            report_step_info.clear()
        else:
            response = tls.createTestCase(
                testcasename=json_parse.read_test_case_name(
                    json_test_data, test),
                testsuiteid=testlink_testsuite_id,
                testprojectid=testlink_testproject_id,
                authorlogin=testlink_user,
                summary='',
                steps=step_info)
            test_case_id = response[0]['id']
            tc_aa_full_ext_id = tls.getTestCase(
                test_case_id)[0]['full_tc_external_id']
            logger.info("Test case created: " + str(response))
            logger.debug("Test case id: " + str(test_case_id))
            logger.debug("Test case_ext_id: " + str(tc_aa_full_ext_id))

            response = tls.addTestCaseToTestPlan(testlink_testproject_id,
                                                 testlink_testplan_id,
                                                 tc_aa_full_ext_id,
                                                 test_case_version)
            logger.info("Test case added to TP: " + str(response))

            new_result = tls.reportTCResult(
                testcaseid=test_case_id,
                testplanid=testlink_testplan_id,
                buildid=testlink_build_id,
                status=json_parse.read_test_case_status(json_test_data, test),
                execduration=json_parse.read_test_case_exec(
                    json_test_data, test),
                timestamp=json_parse.read_test_case_start_time(
                    json_test_data, test),
                steps=report_step_info)
            logger.info("Test case report created: " + str(response))

            log_info = json_parse.read_test_case_logs(json_test_data, test)
            logger.debug(log_info)
            json_parse.csv_write(log_info, log_path)

            new_result_id = new_result[0]['id']
            try:
                new_attachment = tls.uploadExecutionAttachment(
                    log_path, new_result_id, "logfile",
                    'Test case logfile for a AWN Execution run')
                logger.info("Test case attachment upload done :" +
                            str(new_attachment))
            except TLResponseError:
                pass

            report_step_info.clear()
        step_info.clear()

    logger.info("Report logs upload done")

    logger.info("Test reporting completed!")
コード例 #24
0
ファイル: testLinkApi.py プロジェクト: anymoreT/demoForPyQa
import testlink
import pdb
#
SERVER_URL = "http://192.168.31.33:8081/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
DEVKEY = "3cf104e94144c956cdf3ef999318dce7"
tls = testlink.TestlinkAPIClient(SERVER_URL, DEVKEY)
print(tls.about())
print(tls.getProjects())
#获取测试计划信息
# tl = tls.getTestPlanByName("3D旅游_APP", "API验证");
#
# print("test plan")
# print(tl)
# res = tls.getTestCasesForTestPlan(testplanid = int(tl[0]["id"]))
pdb.set_trace()

#{'name': 'huangyong', 'testproject_id': '7251', 'api_key': 'b7beff6630175696b22c91f7185923cde063477709507eb2c388cf943fa43601', 'is_public': '1', 'id': '24541', 'notes': '<p>\n\t验证脚本修改测试计划结果</p>', 'active': '1', 'is_open': '1'}

#获取id
response = tls.getTestCaseIDByName("手机号码-登录按钮")
caseId = response[0]["id"]
#修改测试计划下的结果
response = tls.reportTCResult(testplanid=24541,
                              testcaseid=caseId,
                              buildid=14,
                              status="f")
#pdb.set_trace()

# class TestLink:
#     SERVER_URL = "http://192.168.31.33:8081/testlink/lib/api/xmlrpc/v1/xmlrpc.php"
#     DEVKEY = "3cf104e94144c956cdf3ef999318dce7"
コード例 #25
0
ファイル: testLinkApi.py プロジェクト: anymoreT/demoForPyQa
 def connectTestLink(self):
     self.testLinkInstance = testlink.TestlinkAPIClient(TestLink.SERVER_URL, TestLink.DEVKEY)
     return self.testLinkInstance
コード例 #26
0
 def __init__(self):
     # url = 'http://git.nationalchip.com/testlink/lib/api/xmlrpc.php'
     url = "http://192.168.110.246/testlink/lib/api/xmlrpc.php"
     key = 'f5df4f1bd2bdd22403ec6b8b118d022c'
     self.tlc = testlink.TestlinkAPIClient(url, key)
コード例 #27
0
    def set_proxy(self, host, port=None, headers=None):
        self.proxy = host, port
        self.proxy_headers = headers
        self.contex = ssl._create_unverified_context()

    def make_connection(self, host):
        connection = http.client.HTTPSConnection(*self.proxy,
                                                 context=self.contex)
        connection.set_tunnel(host)
        self._connection = host, connection
        return connection


proxy = ProxiedTransport()
proxy.set_proxy("139.186.2.80", 37491)
tlc = testlink.TestlinkAPIClient(url, key, transport=proxy)

# tlc = testlink.TestlinkAPIClient(url, key)


def update_case_status(testplan_id, case_id, status):
    try:
        tlc.reportTCResult(testcaseid=case_id,
                           testplanid=testplan_id,
                           buildname=build_name,
                           status=status)
        print(case_id)
        return True
    except Exception as e:
        print(e)
        return False