class TestLinkProcess: common = config['common'] conn_testlink = testlink.TestLinkHelper(common.TESTLINK_API_URL,common.TESTLINK_API_KEY) \ .connect(testlink.TestlinkAPIClient) @classmethod def get_project_info(cls) -> list: projects = cls.conn_testlink.getProjects() projects_info = [] __subkey = ['id','name','prefix'] for project in projects: projects_info.append({key: project[key] for key in __subkey}) return projects_info @classmethod def get_test_plan_info(cls) ->list: test_plans = cls.conn_testlink.getProjectTestPlans(cls.get_project_info()[2].get('id')) return test_plans @classmethod def get_test_cases_by_test_plan(cls) ->list: test_suites = cls.conn_testlink.getFirstLevelTestSuitesForTestProject(cls.common.TESTLINK_TESTPROJECT_ID) test_cases = [] for test_suite in test_suites: for case in cls.conn_testlink.getTestCasesForTestSuite(test_suite['id'], True, None): case.update({'testlink_testsuite_name':test_suite.get('name','')}) test_cases.append(case) return test_cases
def __init__(self): os.environ[ 'TESTLINK_API_PYTHON_SERVER_URL'] = "{Your testlink url}/lib/api/xmlrpc/v1/xmlrpc.php" os.environ[ 'TESTLINK_API_PYTHON_DEVKEY'] = "{Tour testlink dev api key}" tl_helper = testlink.TestLinkHelper() self.testlinker = tl_helper.connect(testlink.TestlinkAPIClient)
def __init__(self, methodName): super().__init__(methodName) SERVER_URL = 'http://192.168.50.169/testlink/lib/api/xmlrpc/v1/xmlrpc.php' DEV_KEY = 'ec98b68c3121de5184d2a138558764fd' self.client = testlink.TestLinkHelper(server_url=SERVER_URL, devkey=DEV_KEY).connect( testlink.TestlinkAPIClient) self.logger = logging.getLogger()
def __init__(self, planId, projectId, userKey): ''' For startup testLink we should have server URL and user keys generated through GUI ''' os.environ[ "TESTLINK_API_PYTHON_SERVER_URL"] = "http://<test link server>/lib/api/xmlrpc/v1/xmlrpc.php" os.environ[ "TESTLINK_API_PYTHON_DEVKEY"] = userKey #"e4ba9a9f6e3f8cda0a96a989bd8082b2" #Automation user on Testlink self.tls = testlink.TestLinkHelper().connect( testlink.TestlinkAPIClient) self.projectID = projectId self.testPlanID = planId
def SubmitResultToTestLink(self, testcaseid, testplanid, user, buildname, result, note, testlinkAPI, platformid='0'): os.environ['TESTLINK_API_PYTHON_DEVKEY'] = testlinkAPI self.testcaseid = testcaseid self.testplanid = testplanid self.buildname = buildname self.result = result self.note = note self.user = user self.platformid = platformid tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient) tls.reportTCResult(testcaseid=self.testcaseid, testplanid=self.testplanid, buildname=self.buildname, status=self.result, notes=self.note)
def __init__(self): self.config = { 'username': '******', 'api_key': 'bae5852b0e4a8ac7faa16befb5216c2d', 'url': 'http://127.0.0.1/testlink/lib/api/xmlrpc/v1/xmlrpc.php', 'project_id': '0', 'plan_id': '0', 'platform_id': '0', 'build_id': '0', 'build_name': '' } os.environ["TESTLINK_API_PYTHON_SERVER_URL"] = self.config['url'] os.environ["TESTLINK_API_PYTHON_DEVKEY"] = self.config['api_key'] self.setting = Settings('testlink.cfg') try: self.tlh = testlink.TestLinkHelper() self.tls = self.tlh.connect(testlink.TestlinkAPIClient) except TLResponseError as err: print(err)
def call_test_link_api(file_path): """Handles the API calls to TestLink Args: file_path (str): The path to a file containing test cases to upload Returns: tl_api_response (dict): Metadata about the API response """ sys.path.append(os.path.split(file_path)[0]) test_file_path = os.path.split(file_path)[1].split('.py')[0] imported_test_file = __import__(test_file_path) test_class_name = test_file_path.replace('test', 'Tc').replace( '_', ' ').title().replace(' ', '') tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient) count_cases_uploaded = tls.bulkTestCaseUpload( getpass.getuser(), file_path, getattr(imported_test_file, test_class_name)) tl_api_response = { 'test_file': test_file_path, 'uploaded_cases': count_cases_uploaded } return tl_api_response
def OnCheckbtn(self, event): api_temp_url = self.urltext.GetValue() api_temp_key = self.keytext.GetValue() api_temp_proxy = self.proxytext.GetValue() if not api_temp_proxy: if api_temp_url and api_temp_key: #check the link to testlink try: tl_helper = testlink.TestLinkHelper( api_temp_url, api_temp_key) rf2testlinker = tl_helper.connect( testlink.TestlinkAPIClient) except Exception, e: dlg = wx.MessageDialog(self, str(e), 'Error Message', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return try: checkresult = rf2testlinker.checkDevKey(api_temp_key) except Exception, e: dlg = wx.MessageDialog(self, str(e), 'Error Message', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return if checkresult: self.isChecked = True self.okbtn.Enable() dlg = wx.MessageDialog( self, 'The testlink xmlrpc api can be connect successfully', 'Feedback', wx.OK) dlg.ShowModal() dlg.Destroy()
if isinstance(rsp, dict) and rsp.has_key('msg'): str = rsp['msg'] return TSDuplication(str) #raise TSRSPException(str) raise TSRSPException( 'While import the testsuite,the error response from testlink,abort' ) if __name__ == '__main__': path = 'C:/Users/TOSHIBA/Desktop/2012/testcaseexample-1.xls' ''' reader=ExcelReader(path) print MANDATORYPROP print TC_MANDATORYPROP print TS_MANDATORYPROP gen=reader.read_all_row(0,0) for text in gen: print text print reader.process_title_seq(0) ''' os.environ[ 'TESTLINK_API_PYTHON_SERVER_URL'] = "http://192.168.1.200/testlink/lib/api/xmlrpc/v1/xmlrpc.php" os.environ[ 'TESTLINK_API_PYTHON_DEVKEY'] = "63a71a1af47e7df26ed40e8533bb54da" project_name = 'test_for_autoupdate' tl_helper = testlink.TestLinkHelper() rf2testlinker = tl_helper.connect(testlink.TestlinkAPIClient) task = ImportTSandTC(rf2testlinker, path, 0, project_name) task.process()
# create a testsuite suite = TestLoader().loadTestsFromTestCase(TestSimple) # 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]
def GetTLAPIClient(self): print("Creating a TestLink API Client object to help work with TestLink Operations...") print("Server URL used : %s " % self.TESTLINK_API_PYTHON_SERVER_URL) print("Using the hardcoded Dev key for authorization...") TestLinkObj= testlink.TestLinkHelper(server_url=self.TESTLINK_API_PYTHON_SERVER_URL, devkey=self.TESTLINK_API_PYTHON_DEVKEY).connect(testlink.TestlinkAPIClient) return TestLinkObj
# run the testsuite result = runner.run(suite) # print json output pprint(result.jsonify()) passedTest = list( map(lambda test: test._testMethodName, result.successes)) print(passedTest) if 'test_detectChangesInSortedHighest' in passedTest: resultTest = 'p' else: resultTest = 'f' tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient) tc_info = tls.getTestCase(None, testcaseexternalid='TA-6') print(tc_info) tc_info = tls.getProjectTestPlans('1') print(tc_info) # tls.reportTCResult(4, 2, 'SampleBuild', 'f', 'some notes', user='******', platformid='1') tls.reportTCResult(None, 2, None, resultTest, 'some notes', guess=True, testcaseexternalid='TA-6', platformname='platform', execduration=3.9,
def update_test_case(test_case_id, test_plan_id, build_name, status, notes): tls = testlink.TestLinkHelper(os.environ['TESTLINK_API_PYTHON_SERVER_URL'], os.environ['TESTLINK_API_PYTHON_DEVKEY']).connect(testlink.TestlinkAPIClient) response = tls.reportTCResult(int(test_case_id), int(test_plan_id), build_name, status, notes) print response
def initTestlinkConnect(self): return testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient)
# Uruchomienie testów (pomiar czasu wykonania wszystkich testów). test_suite_time_start = time.time() result = runner.run(suite) test_suite_time_end = time.time() test_suite_exec_time = test_suite_time_end - test_suite_time_start unittests_json_result = result.jsonify() pprint(unittests_json_result) # Konfiguracja połączenia z TestLink. TESTLINK_SERVER_URL = "http://185.24.216.248:81/testlink/lib/api/xmlrpc/v1" \ "/xmlrpc.php" TESTLINK_API_KEY = "5eb00dff1f7220d65e99fdbb9c947f4c" tlh = testlink.TestLinkHelper(TESTLINK_SERVER_URL, TESTLINK_API_KEY) tls = testlink.TestlinkAPIClient(tlh._server_url, tlh._devkey, verbose=False) # --------------------------------------------------------------------------- print("Statystyki TestLink") print( "\t-Number of Projects in TestLink: %s " % tls.countProjects()) print( "\t-Number of Platforms (in TestPlans): %s " % tls.countPlatforms()) print("\t-Number of Builds : %s " % tls.countBuilds()) print( "\t-Number of TestPlans : %s " % tls.countTestPlans()) print( "\t-Number of TestSuites : %s " % tls.countTestSuites()) print( "\t-Number of TestCases (in TestPlans) : %s " % tls.countTestCasesTP())