Skip to content

Commit 82605cd

Browse files
authored
Merge pull request #80 from ekreutz/start_test_run
Don't update project separately while starting test run
2 parents c3cb654 + 760e427 commit 82605cd

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2.41.4
2+
* Don't separately update project when calling start_test_run()
13
2.41.3
24
* Isolate Pillow import, with fallback if import fails
35
2.41.2

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.41.3'
6+
version = '2.41.4'
77

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

testdroid/__init__.py

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from optparse import OptionParser
55
from datetime import datetime
66

7-
__version__ = '2.41.3'
7+
__version__ = '2.41.4'
88

99
FORMAT = "%(message)s"
1010
logging.basicConfig(format=FORMAT)
@@ -426,45 +426,38 @@ def set_project_framework(self, project_id, frameworkId):
426426
""" Start a test run on a device group
427427
"""
428428
def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None, additional_params={}):
429-
me = self.get_me()
430-
payload={} if name is None else {'name':name}
429+
# check project validity
431430
project = self.get_project(project_id)
432431
if not 'id' in project:
433432
print "Project %s not found" % project_id
434433
sys.exit(1)
435434

436-
if device_group_id is None and device_model_ids is None:
437-
print "Device group or device models must be defined"
438-
sys.exit(1)
439-
440-
if device_group_id is not None:
441-
device_group = self.get("users/%s/device-groups/%s" % (me['id'], device_group_id))
442-
if not 'id' in device_group:
443-
print "Device group %s not found" % device_group_id
444-
sys.exit(1)
445-
446-
if int(device_group['deviceCount']) == 0:
447-
print "ERROR: No devices at device group %s" % device_group['id']
448-
sys.exit(1)
435+
# start populating parameters for the request payload...
436+
payload={}
449437

450-
# Update device group
451-
reply = self.set_project_config(project_id=project_id, payload={'usedDeviceGroupId': device_group_id})
452-
if int(reply['usedDeviceGroupId']) != int(device_group_id):
453-
print "Unable to set used device group to %s for project %s" % (device_group_id, project_id)
454-
sys.exit(1)
455-
print "Starting test run on project %s \"%s\" using device group %s \"%s\"" % (project['id'], project['name'], device_group['id'], device_group['displayName'])
438+
if name is not None:
439+
payload['name'] = name
456440

441+
if device_group_id is not None:
442+
payload['usedDeviceGroupId'] = device_group_id
443+
print "Starting test run on project %s \"%s\" using device group %s" % (project['id'], project['name'], device_group_id)
444+
elif device_model_ids is not None:
445+
payload['usedDeviceIds[]'] = device_model_ids
446+
print "Starting test run on project %s \"%s\" using device models ids %s" % (project['id'], project['name'], device_model_ids)
457447
else:
458-
payload={'usedDeviceIds[]': device_model_ids}
459-
print "Starting test run on project %s \"%s\" using device models ids %s " % (project['id'], project['name'], device_model_ids)
448+
print "Either device group or device models must be defined"
449+
sys.exit(1)
460450

461-
# Start run
462-
path = "/users/%s/projects/%s/runs" % ( me['id'], project_id )
451+
# add optional request params that the user might have specified
463452
payload.update(additional_params)
464-
reply = self.post(path=path, payload=payload)
465-
print "Test run id: %s" % reply['id']
466-
print "Name: %s" % reply['displayName']
467-
return reply['id']
453+
454+
# actually start the test run
455+
me = self.get_me()
456+
path = "/users/%s/projects/%s/runs" % (me['id'], project_id)
457+
test_run = self.post(path=path, payload=payload)
458+
print "Test run id: %s" % test_run['id']
459+
print "Name: %s" % test_run['displayName']
460+
return test_run['id']
468461

469462

470463
""" Start a test run on a device group and wait for completion

0 commit comments

Comments
 (0)