Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var/
.installed.cfg
*.egg
.idea
myenv/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ deploy:
secure: YIvWzNQAUsnxUNQGtGBKAdA9qJBCoaxVudbmO68OCQJ8x4iseNH321tUCihO3ZVeEkyduXEHIK85Club0CEgLvANoGnAOeLPWs+xCljagPBwjtjM7BAtIpojOCCd69OhZfF8pYuUNHL1Ja6NmwoNXSLwhDpTDJVQp0v+dOVAjJg=
on:
tags: true
skip_existing: true
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.69.1
* Added warning about deprecated methods
* Upload returns as json
2.69.0
* Added support for access groups
2.61.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![PyPI version](https://badge.fury.io/py/testdroid.svg)](https://badge.fury.io/py/testdroid)
[![Build Status](https://travis-ci.org/bitbar/testdroid-api-client-python.svg?branch=devel)](https://travis-ci.org/bitbar/testdroid-api-client-python)

Python client for Testdroid Cloud APIv2
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys, os


version = '2.69.0'
version = '2.69.1'

setup(name='testdroid',
version=version,
Expand All @@ -16,7 +16,7 @@
keywords='testdroid rest api client',
author='Henri Kivelä <henri.kivela@bitbar.com>, Sakari Rautiainen <sakari.rautiainen@bitbar.com>, Teppo Malinen <teppo.malinen@bitbar.com>, Jarno Tuovinen <jarno.tuovinen@bitbar.com>, Atte Keltanen <atte.keltanen@bitbar.com>',
author_email='info@bitbar.com',
url='http://www.testdroid.com',
url='http://www.bitbar.com',
license='Apache License v2.0',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
Expand Down
57 changes: 34 additions & 23 deletions testdroid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from optparse import OptionParser
from datetime import datetime

__version__ = '2.69.0'
__version__ = '2.69.1'

FORMAT = "%(message)s"
logging.basicConfig(format=FORMAT)
Expand Down Expand Up @@ -240,7 +240,7 @@ def upload(self, path=None, filename=None):
res = requests.post(url, files=files, headers=self._build_headers())
if res.status_code not in list(range(200, 300)):
raise RequestResponseError(res.text, res.status_code)
return res
return res.json()

""" GET from API resource
"""
Expand Down Expand Up @@ -391,27 +391,30 @@ def print_projects(self, limit=0):
for project in self.get_projects(limit)['data']:
print("%s %s \"%s\"" % (str(project['id']).ljust(10), project['type'].ljust(15), project['name']))

""" Upload application file to project
""" ***DEPRECATED*** Upload application file to project
Consider using upload_file() instead.
"""
def upload_application_file(self, project_id, filename):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
me = self.get_me()
path = "users/%s/projects/%s/files/application" % (me['id'], project_id)
self.upload(path=path, filename=filename)
return self.upload(path=path, filename=filename)

""" Upload application file to project
"""
def upload_file(self, filename):
me = self.get_me()
path = "users/%s/files" % (me['id'])
res = self.upload(path=path, filename=filename).json()
print("ID:%s Name:%s Size:%s" % (str(res['id']).ljust(10), res['name'].ljust(15), res['size']))
return self.upload(path=path, filename=filename)

""" Upload test file to project
""" ***DEPRECATED*** Upload test file to project
Consider using upload_file() instead.
"""
def upload_test_file(self, project_id, filename):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
me = self.get_me()
path = "users/%s/projects/%s/files/test" % (me['id'], project_id)
self.upload(path=path, filename=filename)
return self.upload(path=path, filename=filename)

""" Delete project parameter
"""
Expand All @@ -426,12 +429,14 @@ def get_project_parameters(self, project_id):
path = "me/projects/%s/config/parameters" % ( project_id )
return self.get(path=path)

""" Upload additional data file to project
""" ***DEPRECATED*** Upload additional data file to project
Consider using upload_file() instead.
"""
def upload_data_file(self, project_id, filename):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
me = self.get_me()
path = "users/%s/projects/%s/files/data" % (me['id'], project_id)
self.upload(path=path, filename=filename)
return self.upload(path=path, filename=filename)

""" Set project parameters
"""
Expand All @@ -447,9 +452,11 @@ def get_project_config(self, project_id):
path = "me/projects/%s/config" % ( project_id )
return self.get(path=path)

""" Set project config according to http://docs.testdroid.com/_pages/client.html#project-config
""" ***DEPRECATED*** Set project config
Consider using start_test_run_using_config() instead.
"""
def set_project_config(self, project_id, payload):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
#set the project config to reflect the given json payload
#e.g.: {'usedDeviceGroupId': 1234}
if isinstance(payload, str):
Expand All @@ -458,13 +465,15 @@ def set_project_config(self, project_id, payload):
path = "users/%s/projects/%s/config" % ( me['id'], project_id )
return self.post(path=path, payload=payload)

"""Set project framework based on a framework integer id
""" ***DEPRECATED*** Set project framework based on a framework integer id
Consider using start_test_run_using_config() instead.
"""
def set_project_framework(self, project_id, frameworkId):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
path = "projects/%(project_id)s/frameworks" % {
'project_id': project_id
}
self.post(path, payload={"frameworkId": frameworkId})
return self.post(path, payload={"frameworkId": frameworkId})


""" Start a test run using test run config
Expand All @@ -484,9 +493,11 @@ def start_test_run_using_config(self, test_run_config={}):
test_run = self.post(path=path, payload=test_run_config, headers={'Content-type': 'application/json', 'Accept': 'application/json'})
return test_run

""" Start a test run on a device group
""" ***DEPRECATED*** Start a test run on a device group
Consider using start_test_run_using_config() instead.
"""
def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None, additional_params={}):
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
# check project validity
project = self.get_project(project_id)
if not 'id' in project:
Expand Down Expand Up @@ -947,7 +958,7 @@ class MyParser(OptionParser):
def format_epilog(self, formatter):
return self.epilog
usage = "usage: %prog [options] <command> [arguments...]"
description = "Client for Testdroid Cloud API v2"
description = "Client for Bitbar Cloud API v2"
epilog = """
Commands:

Expand All @@ -965,16 +976,16 @@ def format_epilog(self, formatter):
CALABASH_IOS
delete-project <id> Delete a project
projects Get projects
upload-application <project-id> <filename> Upload application to project
upload-test <project-id> <filename> Upload test file to project
upload-data <project-id> <filename> Upload additional data file to project
upload-application <project-id> <filename> ***DEPRECATED*** Upload application to project
upload-test <project-id> <filename> ***DEPRECATED*** Upload test file to project
upload-data <project-id> <filename> ***DEPRECATED*** Upload additional data file to project
upload-file <filename> Upload to "Files"
set-project-config <project-id> <config-json>
Change the project config parameters as facilitated by the API:
http://docs.testdroid.com/_pages/client.html#project-config
***DEPRECATED*** Change the project config parameters as facilitated by the API:
e.g.:
./testdroid-api-client set-project-config 1234 '{"limitationType":"CLASS", "limitationValue":"com.foo.test.VerifyFoo"}'
start-test-run <project-id> <device-group-id> Start a test run
start-test-run <project-id> <device-group-id>
***DEPRECATED*** Start a test run
start-wait-download-test-run <project-id> <device-group-id>
Start a test run, await completion (polling) and
download results
Expand All @@ -996,7 +1007,7 @@ def format_epilog(self, formatter):
See the sample of Jenkisfile in http://docs.bitbar.com/build-service/guide.html
update-job <job-id> <job-name> <job-configuration>
Update existing job
create-build <job-id> <build-configuration> Create a new build job. See https://cloud.testdroid.com/cloud/swagger-ui.html
create-build <job-id> <build-configuration> Create a new build job. See https://cloud.bitbar.com/cloud/swagger-ui.html
for details of build configuration
delete-job <job-id> Delete job and all the builds in it
delete-build <job-id> <build-id> Delete build by id
Expand Down Expand Up @@ -1032,7 +1043,7 @@ def format_epilog(self, formatter):
"""
parser = MyParser(usage=usage, description=description, epilog=epilog, version="%s %s" % ("%prog", __version__))
parser.add_option("-k", "--apikey", dest="apikey",
help="API key - the API key for Testdroid Cloud. Optional. You can use environment variable TESTDROID_APIKEY as well.")
help="API key - the API key for Bitbar Cloud. Optional. You can use environment variable TESTDROID_APIKEY as well.")
parser.add_option("-u", "--username", dest="username",
help="Username - the email address. Optional. You can use environment variable TESTDROID_USERNAME as well.")
parser.add_option("-p", "--password", dest="password",
Expand Down
10 changes: 5 additions & 5 deletions testdroid/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_upload(self):
url = '{}/{}'.format(URL_API, path)
responses.add(responses.POST, url, json=JSON, status=200)
response = t.upload(path, file_path)
self.assertEqual(response.status_code, 200)
self.assertEqual(response, JSON)

@responses.activate
def test_get_me(self):
Expand Down Expand Up @@ -194,19 +194,20 @@ def test_start_test_run(self):
'id': USER_ID,
'name': 'Sample project',
}

responses.add(responses.GET, url, json=json, status=200)

responses.add(responses.GET, URL_API_ME, json=json, status=200)

url = '{}/projects/{}/runs'.format(
URL_USERS, PROJECT_ID)
json = {
'id': 12,
'displayName': "My test run"
}


responses.add(responses.POST, url, json=json, status=201)
self.assertEqual(t.start_test_run(PROJECT_ID, DEVICE_GROUP_ID), json['id'])
self.assertEqual(t.start_test_run(PROJECT_ID, DEVICE_GROUP_ID), json['id'])

@responses.activate
def test_delete_project_parameters(self):
Expand All @@ -216,9 +217,8 @@ def test_delete_project_parameters(self):
json = {
'id': USER_ID
}

responses.add(responses.GET, URL_API_ME, json=json, status=200)
responses.add(responses.DELETE, url, json=JSON, status=204)
response = t.delete_project_parameters(PROJECT_ID, PARAM_ID)
self.assertEqual(response.status_code, 204)