def test_callServer_ProtocolError(self): """ test _callServer() - Server raises ProtocollError """ server_url = TestLinkHelper()._server_url bad_server_url = server_url.split('xmlrpc.php')[0] client = TestLinkHelper(bad_server_url).connect(TestlinkAPIClient) def a_func(api_client): api_client._callServer('sayHello') self.assertRaises(testlinkerrors.TLConnectionError, a_func, client)
def __init__(self): tlk_helper = TestLinkHelper() try: self.testlink = tlk_helper.connect(TestlinkAPIClient) # 连接TestLink except Exception as e: logger.error('连接testlink失败:%s' % e) exit()
def setUp(self): """Initialisation """ # precondition - SERVEUR_URL and KEY are defined in environment # TESTLINK_API_PYTHON_SERVER_URL=http://localhost/testlink/lib/api/xmlrpc.php # TESTLINK_API_PYTHON_DEVKEY=7ec252ab966ce88fd92c25d08635672b self.client = TestLinkHelper().connect(TestLink)
def test_callServer_FaultError(self): """ test _callServer() - Server raises Fault Error """ client = TestLinkHelper().connect(TestlinkAPIClient) def a_func(api_client): api_client._callServer('sayGoodBye') self.assertRaises(testlinkerrors.TLAPIError, a_func, client)
def test_callServer_socketError(self): """ test _callServer() - Server raises a socket Error (IOError) """ bad_server_url = 'http://111.222.333.4/testlink/lib/api/xmlrpc.php' client = TestLinkHelper(bad_server_url).connect(TestlinkAPIClient) def a_func(api_client): api_client._callServer('sayHello') self.assertRaises(testlinkerrors.TLConnectionError, a_func, client)
def start_suite(self, data, result): self.robot_variables.check_variables() if self.tls is None: self.tls = TestLinkHelper( self.robot_variables.server, self.robot_variables.devkey).connect(TestlinkAPIClient) self.report_kwargs = self.robot_variables.get_report_kwargs() self.test_prefix = self._get_prefix_from_testlink( self.robot_variables.testprojectname)
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()
def __init__(self): tlk_helper = TestLinkHelper( server_url= 'http://192.168.202.174/testlink-1.9.17/lib/api/xmlrpc/v1/xmlrpc.php', devkey='0b839ca6b6a4d8b78139e5f5f93c38f1') try: self.testlink = tlk_helper.connect(TestlinkAPIClient) # 连接TestLink except Exception as e: logger.error('连接testlink失败:%s' % e) exit()
def afterEditing(self): self.parentApp.host = self.hostBox.value self.parentApp.devkey = self.devkeyBox.value try: self.statusBox.value = 'Connecting...' tlh = TestLinkHelper(server_url='http://'+self.parentApp.host+'/lib/api/xmlrpc/v1/xmlrpc.php', devkey=self.parentApp.devkey) self.parentApp.tl = tlh.connect(TestlinkAPIClient) self.parentApp.tl.sayHello() except testlinkerrors.TLConnectionError as err: self.statusBox.value = err else: self.parentApp.setNextForm('IMPORT')
def run_report(): testcases = get_testcase() project = get_project() run_num = 0 failed_list = [] test_project = project[0] test_plan = project[1] test_build = project[2] tls = TestLinkHelper().connect(TestlinkAPIClient) # connect to Testlink testplan_id_result = tls.getTestPlanByName(test_project, test_plan) # get test plan id testplan_id = testplan_id_result[0]['id'] for i in testcases: index = i[0] test_result = i[1] test_notes = i[2] testcase_name = i[3] # testcase_id_result = tls.getTestCaseIDByName(testcase_name) # get test case id # testcase_id = testcase_id_result[0]['id'] # tls.reportTCResult(testcase_id, testplan_id, test_build, test_result, test_notes) try: testcase_id_result = tls.getTestCaseIDByName( testcase_name) # get test case id testcase_id = testcase_id_result[0]['id'] tls.reportTCResult(testcase_id, testplan_id, test_build, test_result, test_notes) run_num += 1 except TestLinkError as e: failed_list.append((index, testcase_name, e)) if len(failed_list) > 0: log_name = 'logFile_%s.txt' % time.time() curr_dir = os.path.dirname(os.path.abspath(__file__)) dest_dir = os.path.join(curr_dir, new_dir) try: os.makedirs(dest_dir) except OSError: pass log_file = os.path.join(dest_dir, log_name) with open(log_file, 'w') as f: for item in failed_list: f.write('-----'.join(str(i) for i in item) + '\n') print '%s test case(s) has been written into log file.' % len(failed_list) print '%s test case(s) has been executed.' % run_num
def create_api_client(self, client_class='TestlinkAPIClient', server_url=None, devkey=None): """Creates a new TestLink-API-Python-client (XMLRPC), using Python class TestlinkAPIClient or TestlinkAPIGeneric. """ a_server_url = server_url or self._server_url a_devkey = devkey or self._devkey a_helper = TestLinkHelper(a_server_url, a_devkey) a_class_name = client_class or self._client_class a_api_class = globals()[a_class_name] self.api_client = a_helper.connect(a_api_class) return self.api_client
def iterTCasesfromTProject(api, TProjName, date1, date2): """ returns as iterator all test cases of project TPROJTNAME, which are created between DATE1 and DATE2 DATE1 and DATE2 must be of type time.struct_time """ TProjId = api.getTestProjectByName(TProjName)[0]['id'] for TSinfo in api.getFirstLevelTestSuitesForTestProject(TProjId): TSuiteId = TSinfo['id'] for TCid in api.getTestCasesForTestSuite(TSuiteId, deep=1, details='only_id'): TCdata = api.getTestCase(TCid)[0] #really only one TC? dateTC = time.strptime(TCdata['creation_ts'][:10], '%Y-%m-%d') if (date1 <= dateTC) and (dateTC <= date2): yield TCdata if __name__ == '__main__': tlapi = TestLinkHelper().connect(TestlinkAPIClient) projName = 'NEW_PROJECT_API' currentTime = time.localtime() oldTime = time.localtime(time.time() - 3600 * 24 * 7) print '%s test cases created between %s and %s' % \ (projName, time.strftime('%Y-%m-%d', oldTime), time.strftime('%Y-%m-%d', currentTime)) for TCdata in iterTCasesfromTProject(tlapi, projName, oldTime, currentTime): print ' %(name)s %(version)s %(creation_ts)s' % TCdata
def setUpClass(cls): cls.api = TestLinkHelper().connect(DummyAPIClient)
def connect_testlink(self): return TestLinkHelper(self.testlink_server, self.dev_key).connect(TestlinkAPIGeneric)
def test_callServer_withArgs(self): """ test _callServer() - calling method with args """ client = TestLinkHelper().connect(TestlinkAPIClient) response = client._callServer('repeat', {'str': 'some arg'}) self.assertEqual('You said: some arg', response)
def test_callServer_noArgs(self): """ test _callServer() - calling method with no args """ client = TestLinkHelper().connect(TestlinkAPIClient) response = client._callServer('sayHello') self.assertEqual('Hello!', response)
def setUp(self): self.client = TestLinkHelper().connect(TestlinkAPIGeneric)
def setUp(self): self.api = TestLinkHelper().connect(DummyAPIClient)
return json_out def tearDown(self): self.assertEqual([], self.verificationErrors) if __name__ == '__main__': # redirector default output of unittest to /dev/null with open( os.devnull, 'w' ) as null_stream: runner = TextTestRunner( stream=null_stream ) runner.resultclass = AppDynamicsJob TESTLINK_API_PYTHON_SERVER_URL = 'http://127.0.0.1/testlink/lib/api/xmlrpc/v1/xmlrpc.php' #wpisz swój klucz w dół TESTLINK_API_PYTHON_DEVKEY = '724497bfde0cc05904c85a68a1263c6d' tl_helper = TestLinkHelper(TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY) myTestLink = tl_helper.connect(TestlinkAPIClient) print(myTestLink.connectionInfo()) print(myTestLink.countProjects()) tc_info = myTestLink.getTestCase(None, testcaseexternalid='26-2') print(tc_info) tc_info = myTestLink.getProjectTestPlans('1') print(tc_info) # tls.reportTCResult(4, 2, 'SampleBuild', 'f', 'some notes', user='******', platformid='1') myTestLink.reportTCResult(None, 2, None, 'p', 'some notes', guess=True, testcaseexternalid='26-2', platformname='DPP', execduration=3.9, timestamp='2020-06-10 12:03', steps=[{'step_number': 1, 'result': 'p', 'notes': 'result note for passed step 1'}])
def setUp(self): self.api = TestLinkHelper().connect(DummyAPIGeneric) self.callArgs = None
# precondition a) # SERVER_URL and KEY are defined in environment # TESTLINK_API_PYTHON_SERVER_URL=http://YOURSERVER/testlink/lib/api/xmlrpc.php # TESTLINK_API_PYTHON_DEVKEY=7ec252ab966ce88fd92c25d08635672b # # alternative precondition b) # SERVEUR_URL and KEY are defined as command line arguments # python TestLinkExample.py --server_url http://YOURSERVER/testlink/lib/api/xmlrpc.php # --devKey 7ec252ab966ce88fd92c25d08635672b # # ATTENTION: With TestLink 1.9.7, cause of the new REST API, the SERVER_URL # has changed from # (old) http://YOURSERVER/testlink/lib/api/xmlrpc.php # to # (new) http://YOURSERVER/testlink/lib/api/xmlrpc/v1/xmlrpc.php tl_helper = TestLinkHelper() tl_helper.setParamsFromArgs( '''Shows how to use the TestLinkAPI for CustomFields. => requires an existing project PROJECT_API_GENERIC-*''') myTestLink = tl_helper.connect(TestlinkAPIGeneric) myPyVersion = python_version() myPyVersionShort = myPyVersion.replace('.', '')[:2] NEWTESTPLAN_A = "TestPlan_API_GENERIC A" # NEWTESTPLAN_B="TestPlan_API_GENERIC B" # NEWTESTPLAN_C="TestPlan_API_GENERIC C - DeleteTest" # NEWPLATFORM_A='Big Bird %s' % myPyVersionShort NEWPLATFORM_B = 'Small Bird' # NEWPLATFORM_C='Ugly Bird' NEWTESTSUITE_A = "A - First Level"
def setUpClass(cls): cls.api = TestLinkHelper().connect(DummyAPIGeneric)