|
5 | 5 | from optparse import OptionParser |
6 | 6 | from datetime import datetime |
7 | 7 |
|
8 | | -__version__ = '2.39' |
| 8 | +__version__ = '2.41.2' |
9 | 9 |
|
10 | 10 | FORMAT = "%(message)s" |
11 | 11 | logging.basicConfig(format=FORMAT) |
@@ -426,7 +426,7 @@ def set_project_framework(self, project_id, frameworkId): |
426 | 426 |
|
427 | 427 | """ Start a test run on a device group |
428 | 428 | """ |
429 | | - def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None): |
| 429 | + def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None, additional_params={}): |
430 | 430 | me = self.get_me() |
431 | 431 | payload={} if name is None else {'name':name} |
432 | 432 | project = self.get_project(project_id) |
@@ -461,6 +461,7 @@ def start_test_run(self, project_id, device_group_id=None, device_model_ids=None |
461 | 461 |
|
462 | 462 | # Start run |
463 | 463 | path = "/users/%s/projects/%s/runs" % ( me['id'], project_id ) |
| 464 | + payload.update(additional_params) |
464 | 465 | reply = self.post(path=path, payload=payload) |
465 | 466 | print "Test run id: %s" % reply['id'] |
466 | 467 | print "Name: %s" % reply['displayName'] |
@@ -488,13 +489,14 @@ def wait_test_run(self, project_id, test_run_id): |
488 | 489 | print "Awaiting completion of test run with id %s. Will wait forever polling every %smins." % (test_run_id, Testdroid.polling_interval_mins) |
489 | 490 | while True: |
490 | 491 | time.sleep(Testdroid.polling_interval_mins*60) |
491 | | - self.access_token = None #WORKAROUND: access token thinks it's still valid, |
492 | | - # > token valid for another 633.357925177 |
493 | | - #whilst this happens: |
494 | | - # > Couldn't establish the state of the test run with id: 72593732. Aborting |
495 | | - # > {u'error_description': u'Invalid access token: b3e62604-9d2a-49dc-88f5-89786ff5a6b6', u'error': u'invalid_token'} |
496 | | - |
497 | | - self.get_token() #in case it expired |
| 492 | + if not self.api_key: |
| 493 | + self.access_token = None #WORKAROUND: access token thinks it's still valid, |
| 494 | + # > token valid for another 633.357925177 |
| 495 | + #whilst this happens: |
| 496 | + # > Couldn't establish the state of the test run with id: 72593732. Aborting |
| 497 | + # > {u'error_description': u'Invalid access token: b3e62604-9d2a-49dc-88f5-89786ff5a6b6', u'error': u'invalid_token'} |
| 498 | + |
| 499 | + self.get_token() #in case it expired |
498 | 500 | testRunStatus = self.get_test_run(project_id, test_run_id) |
499 | 501 | if testRunStatus and testRunStatus.has_key('state'): |
500 | 502 | if testRunStatus['state'] == "FINISHED": |
@@ -540,6 +542,11 @@ def print_project_test_runs(self, project_id, limit=0): |
540 | 542 | def get_test_run(self, project_id, test_run_id): |
541 | 543 | return self.get("me/projects/%s/runs/%s" % (project_id, test_run_id)) |
542 | 544 |
|
| 545 | + """Abort a test run |
| 546 | + """ |
| 547 | + def abort_test_run(self, project_id, test_run_id): |
| 548 | + return self.post("me/projects/%s/runs/%s/abort" % (project_id, test_run_id)) |
| 549 | + |
543 | 550 | """ Return device runs for a project |
544 | 551 | """ |
545 | 552 | def get_device_runs(self, project_id, test_run_id, limit=0): |
@@ -602,11 +609,11 @@ def download_test_screenshots(self, project_id, test_run_id): |
602 | 609 | device_runs = self.get_device_runs(project_id, test_run_id) |
603 | 610 | logger.info("Test run %s: \"%s\" has %s device runs:" % (test_run['id'], test_run['displayName'], len(device_runs['data']))) |
604 | 611 | for device_run in device_runs['data']: |
605 | | - logger.info("%s \"%s\" %s" % (device_run['id'], device_run['device']['displayName'], device_run['runStatus'])) |
| 612 | + logger.info("%s \"%s\" %s" % (device_run['id'], device_run['device']['displayName'], device_run['state'])) |
606 | 613 |
|
607 | 614 | logger.info(""); |
608 | 615 | for device_run in device_runs['data']: |
609 | | - if device_run['runStatus'] == "SUCCEEDED": |
| 616 | + if device_run['state'] in ["SUCCEEDED", "FAILED", "ABORTED", "WARNING", "TIMEOUT"]: |
610 | 617 | directory = "%s-%s/%d-%s/screenshots" % (test_run['id'], test_run['displayName'], device_run['id'], device_run['device']['displayName']) |
611 | 618 | screenshots = self.get_device_run_screenshots_list(project_id, test_run_id, device_run['id']) |
612 | 619 | no_screenshots = True |
@@ -638,7 +645,7 @@ def download_test_screenshots(self, project_id, test_run_id): |
638 | 645 | if no_screenshots: |
639 | 646 | logger.info("Device %s has no screenshots - skipping" % device_run['device']['displayName']) |
640 | 647 | else: |
641 | | - logger.info("Device %s has failed or has not finished - skipping" % device_run['device']['displayName']) |
| 648 | + logger.info("Device %s has errored or has not finished - skipping" % device_run['device']['displayName']) |
642 | 649 |
|
643 | 650 | def get_parser(self): |
644 | 651 | class MyParser(OptionParser): |
|
0 commit comments