|
4 | 4 | from optparse import OptionParser
|
5 | 5 | from datetime import datetime
|
6 | 6 |
|
7 |
| -__version__ = '2.41.3' |
| 7 | +__version__ = '2.41.4' |
8 | 8 |
|
9 | 9 | FORMAT = "%(message)s"
|
10 | 10 | logging.basicConfig(format=FORMAT)
|
@@ -426,45 +426,38 @@ def set_project_framework(self, project_id, frameworkId):
|
426 | 426 | """ Start a test run on a device group
|
427 | 427 | """
|
428 | 428 | 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 |
431 | 430 | project = self.get_project(project_id)
|
432 | 431 | if not 'id' in project:
|
433 | 432 | print "Project %s not found" % project_id
|
434 | 433 | sys.exit(1)
|
435 | 434 |
|
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={} |
449 | 437 |
|
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 |
456 | 440 |
|
| 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) |
457 | 447 | 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) |
460 | 450 |
|
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 |
463 | 452 | 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'] |
468 | 461 |
|
469 | 462 |
|
470 | 463 | """ Start a test run on a device group and wait for completion
|
|
0 commit comments