Skip to content

Commit 9601a6f

Browse files
author
Sakari Rautiainen
committed
2 parents fdd17b3 + d00d7cf commit 9601a6f

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2.41.2
2+
* Add api to abort a test run
3+
2.41.1
4+
* Possibility to include additional custom params when launching new test run
5+
2.41.0
6+
* Fixed bug with api access using api_key without login/pass
7+
* Fix for download_test_screenshots method to work with version
8+
2.40
9+
* Fixed download_test_screenshots method to work with 2.39+ version of the Testdroid API
110
2.6.2
211
* Fixes: Init overloading fixed, api key usage for delete and posts
312
* Features: Get project config.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys, os
44

55

6-
version = '2.39'
6+
version = '2.41.2'
77

88
setup(name='testdroid',
99
version=version,

testdroid/__init__.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from optparse import OptionParser
66
from datetime import datetime
77

8-
__version__ = '2.39'
8+
__version__ = '2.41.2'
99

1010
FORMAT = "%(message)s"
1111
logging.basicConfig(format=FORMAT)
@@ -426,7 +426,7 @@ def set_project_framework(self, project_id, frameworkId):
426426

427427
""" Start a test run on a device group
428428
"""
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={}):
430430
me = self.get_me()
431431
payload={} if name is None else {'name':name}
432432
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
461461

462462
# Start run
463463
path = "/users/%s/projects/%s/runs" % ( me['id'], project_id )
464+
payload.update(additional_params)
464465
reply = self.post(path=path, payload=payload)
465466
print "Test run id: %s" % reply['id']
466467
print "Name: %s" % reply['displayName']
@@ -488,13 +489,14 @@ def wait_test_run(self, project_id, test_run_id):
488489
print "Awaiting completion of test run with id %s. Will wait forever polling every %smins." % (test_run_id, Testdroid.polling_interval_mins)
489490
while True:
490491
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
498500
testRunStatus = self.get_test_run(project_id, test_run_id)
499501
if testRunStatus and testRunStatus.has_key('state'):
500502
if testRunStatus['state'] == "FINISHED":
@@ -540,6 +542,11 @@ def print_project_test_runs(self, project_id, limit=0):
540542
def get_test_run(self, project_id, test_run_id):
541543
return self.get("me/projects/%s/runs/%s" % (project_id, test_run_id))
542544

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+
543550
""" Return device runs for a project
544551
"""
545552
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):
602609
device_runs = self.get_device_runs(project_id, test_run_id)
603610
logger.info("Test run %s: \"%s\" has %s device runs:" % (test_run['id'], test_run['displayName'], len(device_runs['data'])))
604611
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']))
606613

607614
logger.info("");
608615
for device_run in device_runs['data']:
609-
if device_run['runStatus'] == "SUCCEEDED":
616+
if device_run['state'] in ["SUCCEEDED", "FAILED", "ABORTED", "WARNING", "TIMEOUT"]:
610617
directory = "%s-%s/%d-%s/screenshots" % (test_run['id'], test_run['displayName'], device_run['id'], device_run['device']['displayName'])
611618
screenshots = self.get_device_run_screenshots_list(project_id, test_run_id, device_run['id'])
612619
no_screenshots = True
@@ -638,7 +645,7 @@ def download_test_screenshots(self, project_id, test_run_id):
638645
if no_screenshots:
639646
logger.info("Device %s has no screenshots - skipping" % device_run['device']['displayName'])
640647
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'])
642649

643650
def get_parser(self):
644651
class MyParser(OptionParser):

0 commit comments

Comments
 (0)