Beispiel #1
0
    class TestLinkHandler(object):

        def __init__(self,test_project,test_plan,build_name,url = 'http://10.99.101.4/testlink/lib/api/xmlrpc/v1/xmlrpc.php',key = '4eb2733b98b4697bfd69d46cd8090c8c'):
            self._url = url
            self._key = key
            self.t = TestlinkAPIClient(url,key)
            self.test_project = test_project
            self.test_plan = test_plan
            self.build_name = build_name
            self.get_info()

        def get_info(self):
            self.project_id = self.t.getProjectIDByName(self.test_project)
            self.plan_id = self.t.getTestPlanByName(self.test_project,self.test_plan)[0]['id']
            print 'plan_id',self.plan_id

        def get_case_id(self,tc_full_id):
            tc = self.t.getTestCasesForTestPlan(self.plan_id)
            case_id = False
            for i,j in tc.items():
                if j[0]['full_external_id'] == tc_full_id:
                    case_id = j[0]['tcase_id']
            return case_id

        def set_tc_status(self,tc_full_id,status,notes=''):
            case_id = self.get_case_id(tc_full_id)
            result = self.t.reportTCResult(testcaseid=case_id,testplanid=self.plan_id,status=status,buildname=self.build_name,notes='')
            return result
Beispiel #2
0
def main(*argv):
    if (argv):
        client = TestlinkAPIClient()
        projects = client.getProjects()
        opts, args = getopt.getopt(argv, None, ["project"])
        p = [x for x in projects if x['name'].lower() == args[0].lower()]
        print dir(p)
        pass
def main(*argv):
    if(argv):
        client = TestlinkAPIClient()
        projects = client.getProjects()
        opts, args =  getopt.getopt(argv, None, ["project"])
        p = [x for x in projects if x['name'].lower()==args[0].lower()]
        print dir(p)
        pass
Beispiel #4
0
 def __init__(self,test_project,test_plan,build_name,url = 'http://10.99.101.4/testlink/lib/api/xmlrpc/v1/xmlrpc.php',key = '4eb2733b98b4697bfd69d46cd8090c8c'):
     self._url = url
     self._key = key
     self.t = TestlinkAPIClient(url,key)
     self.test_project = test_project
     self.test_plan = test_plan
     self.build_name = build_name
     self.get_info()
Beispiel #5
0
 def __init__(self,
              enable=is_test,
              test_project=test_porject,
              test_plan=test_plan,
              build_name=build_name,
              url=url,
              key=key):
     self._url = url
     self._key = key
     self.t = TestlinkAPIClient(url, key)
     self.test_project = test_project
     self.test_plan = test_plan
     self.build_name = build_name
     self.enable = enable
     self.get_info()
Beispiel #6
0
 def init(self, config):
     try:
         self.serverUrl = config.get('testlink', 'serverUrl') 
     except NoSectionError:
         self.serverUrl = ''
     try:
         self.serverKey = config.get('testlink', 'serverKey') 
     except NoSectionError:
         self.serverKey = ''
     self.testlinkclient = TestlinkAPIClient(self.serverUrl, self.serverKey)
Beispiel #7
0
    def __init__(self, testplan, testbuild=None, proj_name=None, tester='lhu'):

        self.testplan = testplan

        key, id, val = self.read_profile('proj_name')
        proj_name = val
        self.proj_name = proj_name
        #    SERVER_URL

        key, id, val = self.read_profile('SERVER_URL')
        self.SERVER_URL = val

        if tester:
            print 'AT_INFO : tester --> ', tester
            #            if self.map_tester_key.has_key(tester):
            #                self.DEV_KEY = self.map_tester_key[tester]
            if not self.read_profile(tester):
                print 'AT_ERROR : tester %s is not defined in profile %s ' % (tester, self.profile_loc)
                raise Exception('AT_ERROR : tester [%s] is not defined in profile [%s] ' % (
                tester, os.path.expandvars(self.profile_loc)))
            name, id, devkey = self.read_profile(tester)

            self.DEV_KEY = devkey

        try:
            myTestLink = TestlinkAPIClient(self.SERVER_URL, self.DEV_KEY)

            if myTestLink.checkDevKey() != True:
                print "AT_ERROR : Error with the testlink devKey.", self.DEV_KEY
                raise Exception('AT_ERROR : Error with the testlink devKey.' + self.DEV_KEY)

            self.myTestLink = myTestLink

        except Exception, e:
            print 'AT_ERROR : ', str(e)
            raise Exception(e)
    def __init__(self,
                 xml=None,
                 testlinkUpdate=False,
                 autoGenerate=False,
                 skipMissing=False,
                 stream=None,
                 testResultClass=TestLinkTestResult,
                 testsdir=None,
                 browser=None):
        print 'Setting up the environment'
        #LOAD THE TESTS from the Directory
        self.testsdir = testsdir or runner_config.TESTS_DIRECTORY
        sys.path.append(self.testsdir)
        from selenium import SeleniumTestCase
        #Setup the browser
        self.browser = browser or selenium_config.browser
        SeleniumTestCase.browser = self.browser
        #End Setup the browser

        #Setup the plan
        self.testcases = []
        if not xml:
            self.xml = open(runner_config.DEFAULT_PLAN, 'r').read()
        else:
            self.xml = open(xml, 'r').read()
        #End Setup the plan

        self.tlupdate = testlinkUpdate
        self.stream = stream
        if not os.path.exists(self.testsdir):
            if self.stream:
                self.stream.write('Tests directory ' + self.testsdir +
                                  ' does not exists, Creating it now...')
            os.makedirs(self.testsdir)
            if self.stream:
                self.stream.write('Tests directory created.')
        self.dom = md.parseString(self.xml)
        self.autoGen = autoGenerate
        self.client = TestlinkAPIClient()
        self.loadTestParams()
        self.loadTCs()
        if self.autoGen: self.createTCs()
        if skipMissing: self.removeMissingTCs()
        self.suite = unittest.TestLoader().loadTestsFromNames(
            [x['fullname'] for x in self.testcases])
        self.tcdict = dict([(x['fullname'], x) for x in self.testcases])
        self.testresult = testResultClass(self)
Beispiel #9
0
class TestlinkHandler(object):
    def __init__(self,
                 enable=is_test,
                 test_project=test_porject,
                 test_plan=test_plan,
                 build_name=build_name,
                 url=url,
                 key=key):
        self._url = url
        self._key = key
        self.t = TestlinkAPIClient(url, key)
        self.test_project = test_project
        self.test_plan = test_plan
        self.build_name = build_name
        self.enable = enable
        if enable == True or enable == 'True':
            self.get_info()

    def get_info(self):
        self.project_id = self.t.getProjectIDByName(self.test_project)
        self.plan_id = self.t.getTestPlanByName(self.test_project,
                                                self.test_plan)[0]['id']
        #print 'plan_id',self.plan_id

    def get_case_id(self, tc_full_id):
        tc = self.t.getTestCasesForTestPlan(self.plan_id)
        case_id = False
        for i, j in tc.items():
            if j[0]['full_external_id'] == tc_full_id:
                case_id = j[0]['tcase_id']
        return case_id

    def set_tc_status(self, tc_full_id, status, notes=''):
        status_dict = {
            True: 'p',
            'True': 'p',
            False: 'f',
            'False': 'f',
            1: 'p',
            '1': 'p',
            0: 'f',
            '0': 'f',
            -1: 'b',
            '-1': 'b',
            'b': 'b',
            'p': 'p',
            'f': 'f',
        }
        try:
            if tc_full_id and (self.enable == True or self.enable == 'True'):
                if isinstance(tc_full_id, list):
                    for case in tc_full_id:
                        case_id = self.get_case_id(case)
                        self.t.reportTCResult(testcaseid=case_id,
                                              testplanid=self.plan_id,
                                              status=status_dict.get(status),
                                              buildname=self.build_name,
                                              notes=notes)
                    return True
                case_id = self.get_case_id(tc_full_id)
                self.t.reportTCResult(testcaseid=case_id,
                                      testplanid=self.plan_id,
                                      status=status_dict.get(status),
                                      buildname=self.build_name,
                                      notes=notes)
                return True
        except Exception, e:
            print e.__repr__()
            return False
Beispiel #10
0
        }
        try:
            if tc_full_id and (self.enable == True or self.enable == 'True'):
                if isinstance(tc_full_id, list):
                    for case in tc_full_id:
                        case_id = self.get_case_id(case)
                        self.t.reportTCResult(testcaseid=case_id,
                                              testplanid=self.plan_id,
                                              status=status_dict.get(status),
                                              buildname=self.build_name,
                                              notes=notes)
                    return True
                case_id = self.get_case_id(tc_full_id)
                self.t.reportTCResult(testcaseid=case_id,
                                      testplanid=self.plan_id,
                                      status=status_dict.get(status),
                                      buildname=self.build_name,
                                      notes=notes)
                return True
        except Exception, e:
            print e.__repr__()
            return False


if __name__ == '__main__':
    projects = u'湖北日报'
    plan = u'湖北日报3.2.3发布性测试'
    b = u'Android湖北日报3.2.3发布性测试'
    tkh = TestlinkHandler()
    t = TestlinkAPIClient(url, key)
Beispiel #11
0
# @{
##
import sys
import time
import pymysql
from testlink import TestlinkAPIClient
from config import getconfig
reload(sys)
sys.setdefaultencoding('utf-8')

testlink_url = getconfig("testlink", "testlink_url")
ip = testlink_url.split("/")[2]
TLURL = testlink_url + "/lib/api/xmlrpc/v1/xmlrpc.php"
DEVKey = getconfig("testlink", "DEVKey")
test_user_name = getconfig("testlink", "test_user_name")
tls = TestlinkAPIClient(TLURL, DEVKey)
nowtime = time.strftime("%Y-%m-%d")


def getsql(sql):
    """
    根据项目名称和文件夹名称查找文件夹对应的
    此方法只能查找到根目录下的文件夹的id,多级目录无法查找
    :param sql: sql语句
    :return:查询结果
    """
    db = pymysql.connect(ip, "testlink", "testlink", "testlink", use_unicode=True, charset="utf8")
    cursor = db.cursor()
    cursor.execute(sql)
    results = cursor.fetchall()
    if len(results) == 0:
Beispiel #12
0
class TestlinkPlugin(IBDTestPlugin):

    testlinkclient = ''
    serverUrl = ''
    serverKey = ''

    def init(self, config):
        try:
            self.serverUrl = config.get('testlink', 'serverUrl') 
        except NoSectionError:
            self.serverUrl = ''
        try:
            self.serverKey = config.get('testlink', 'serverKey') 
        except NoSectionError:
            self.serverKey = ''
        self.testlinkclient = TestlinkAPIClient(self.serverUrl, self.serverKey)

    def activate(self):
        super(TestlinkPlugin, self).activate()
        return "Testlink plugin actif"

    def deactivate(self):
        super(TestlinkPlugin, self).deactivate()
        return "Testlink plugin inactif"

    def run(self, browser, script):
        print("Testlink run %s with %s" % (script, browser))

    def list_projects(self):
        result=[]
        for project in self.testlinkclient.getProjects():
            result.append(
                    {
                        'id': project['id'],
                        'name' : project['name'],
                        })
        return result

    def list_testplans(self, projectid):
        result=[]
        for testplan in self.testlinkclient.getProjectTestPlans(testprojectid=projectid):
            result.append(
                    {
                        'id' : testplan['id'],
                        'name' : testplan['name'],
                        })
        return result

    def list_testcases(self, testplanid):
        result=[]
        testcases = self.testlinkclient.getTestCasesForTestPlan(
                testplanid=testplanid, 
                execution_type=2
                )
        for testcaseid, testcase in testcases.items():
            result.append(
                    {
                        'id' : testcase[0]['tcase_id'],
                        'name' : testcase[0]['tcase_name'],
                        'extid' : testcase[0]['full_external_id'],
                        })
        return result
Beispiel #13
0
        self.createFieldsAndBuildMaps(testlinkprojectid, qtestprojectid,
                                      userlist, usermap, project_manager)
        top_module = self.qclient.createModule(qtestprojectid, testprojectname)
        modules = self.tclient.getFirstLevelTestSuitesForTestProject(
            testprojectid=testlinkprojectid)
        for suite in modules:
            self.buildSuite(testlinkprojectid,
                            suite['id'],
                            qtestprojectid,
                            qtestparentid=top_module)


if __name__ == '__main__':
    with open("config.json") as f:
        c = f.read()
    config = json.loads(c)
    qclient = QtestClient(config["qtest_server_url"], config["qtesttoken"])
    tclient = TestlinkAPIClient(config["testlink_server_url"],
                                config["testlink_devkey"])
    t2q = Testlink2qTest(tclient, qclient)
    qtestproject_list = config["qtestproject_list"]
    testlink_project_list = config["testlink_project_list"]
    userlist = config["project_members"]
    usermap = config["user_map"]
    project_manager = config["project_owner"]
    for testprojectname, qtestprojectname in zip(testlink_project_list,
                                                 qtestproject_list):
        print("Migrating Project " + testprojectname + " ...")
        t2q.move_recursively(testprojectname, qtestprojectname, userlist,
                             usermap, project_manager)