Skip to content

Commit 84cd487

Browse files
author
Sakari Rautiainen
authored
Merge pull request #122 from bitbar/devel
v2.69.1
2 parents d1b8f64 + 61d1f96 commit 84cd487

File tree

7 files changed

+47
-30
lines changed

7 files changed

+47
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var/
2222
.installed.cfg
2323
*.egg
2424
.idea
25+
myenv/
2526

2627
# PyInstaller
2728
# Usually these files are written by a python script from a template

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ deploy:
1616
secure: YIvWzNQAUsnxUNQGtGBKAdA9qJBCoaxVudbmO68OCQJ8x4iseNH321tUCihO3ZVeEkyduXEHIK85Club0CEgLvANoGnAOeLPWs+xCljagPBwjtjM7BAtIpojOCCd69OhZfF8pYuUNHL1Ja6NmwoNXSLwhDpTDJVQp0v+dOVAjJg=
1717
on:
1818
tags: true
19+
skip_existing: true

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.69.1
2+
* Added warning about deprecated methods
3+
* Upload returns as json
14
2.69.0
25
* Added support for access groups
36
2.61.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[![PyPI version](https://badge.fury.io/py/testdroid.svg)](https://badge.fury.io/py/testdroid)
12
[![Build Status](https://travis-ci.org/bitbar/testdroid-api-client-python.svg?branch=devel)](https://travis-ci.org/bitbar/testdroid-api-client-python)
23

34
Python client for Testdroid Cloud APIv2

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys, os
44

55

6-
version = '2.69.0'
6+
version = '2.69.1'
77

88
setup(name='testdroid',
99
version=version,
@@ -16,7 +16,7 @@
1616
keywords='testdroid rest api client',
1717
author='Henri Kivelä <[email protected]>, Sakari Rautiainen <[email protected]>, Teppo Malinen <[email protected]>, Jarno Tuovinen <[email protected]>, Atte Keltanen <[email protected]>',
1818
author_email='[email protected]',
19-
url='http://www.testdroid.com',
19+
url='http://www.bitbar.com',
2020
license='Apache License v2.0',
2121
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
2222
include_package_data=True,

testdroid/__init__.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from optparse import OptionParser
1212
from datetime import datetime
1313

14-
__version__ = '2.69.0'
14+
__version__ = '2.69.1'
1515

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

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

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

401403
""" Upload application file to project
402404
"""
403405
def upload_file(self, filename):
404406
me = self.get_me()
405407
path = "users/%s/files" % (me['id'])
406-
res = self.upload(path=path, filename=filename).json()
407-
print("ID:%s Name:%s Size:%s" % (str(res['id']).ljust(10), res['name'].ljust(15), res['size']))
408+
return self.upload(path=path, filename=filename)
408409

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

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

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

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

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

461-
"""Set project framework based on a framework integer id
468+
""" ***DEPRECATED*** Set project framework based on a framework integer id
469+
Consider using start_test_run_using_config() instead.
462470
"""
463471
def set_project_framework(self, project_id, frameworkId):
472+
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
464473
path = "projects/%(project_id)s/frameworks" % {
465474
'project_id': project_id
466475
}
467-
self.post(path, payload={"frameworkId": frameworkId})
476+
return self.post(path, payload={"frameworkId": frameworkId})
468477

469478

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

487-
""" Start a test run on a device group
496+
""" ***DEPRECATED*** Start a test run on a device group
497+
Consider using start_test_run_using_config() instead.
488498
"""
489499
def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None, additional_params={}):
500+
logger.warning('WARNING: This method has been deprecated and will be removed in the future.')
490501
# check project validity
491502
project = self.get_project(project_id)
492503
if not 'id' in project:
@@ -947,7 +958,7 @@ class MyParser(OptionParser):
947958
def format_epilog(self, formatter):
948959
return self.epilog
949960
usage = "usage: %prog [options] <command> [arguments...]"
950-
description = "Client for Testdroid Cloud API v2"
961+
description = "Client for Bitbar Cloud API v2"
951962
epilog = """
952963
Commands:
953964
@@ -965,16 +976,16 @@ def format_epilog(self, formatter):
965976
CALABASH_IOS
966977
delete-project <id> Delete a project
967978
projects Get projects
968-
upload-application <project-id> <filename> Upload application to project
969-
upload-test <project-id> <filename> Upload test file to project
970-
upload-data <project-id> <filename> Upload additional data file to project
979+
upload-application <project-id> <filename> ***DEPRECATED*** Upload application to project
980+
upload-test <project-id> <filename> ***DEPRECATED*** Upload test file to project
981+
upload-data <project-id> <filename> ***DEPRECATED*** Upload additional data file to project
971982
upload-file <filename> Upload to "Files"
972983
set-project-config <project-id> <config-json>
973-
Change the project config parameters as facilitated by the API:
974-
http://docs.testdroid.com/_pages/client.html#project-config
984+
***DEPRECATED*** Change the project config parameters as facilitated by the API:
975985
e.g.:
976986
./testdroid-api-client set-project-config 1234 '{"limitationType":"CLASS", "limitationValue":"com.foo.test.VerifyFoo"}'
977-
start-test-run <project-id> <device-group-id> Start a test run
987+
start-test-run <project-id> <device-group-id>
988+
***DEPRECATED*** Start a test run
978989
start-wait-download-test-run <project-id> <device-group-id>
979990
Start a test run, await completion (polling) and
980991
download results
@@ -996,7 +1007,7 @@ def format_epilog(self, formatter):
9961007
See the sample of Jenkisfile in http://docs.bitbar.com/build-service/guide.html
9971008
update-job <job-id> <job-name> <job-configuration>
9981009
Update existing job
999-
create-build <job-id> <build-configuration> Create a new build job. See https://cloud.testdroid.com/cloud/swagger-ui.html
1010+
create-build <job-id> <build-configuration> Create a new build job. See https://cloud.bitbar.com/cloud/swagger-ui.html
10001011
for details of build configuration
10011012
delete-job <job-id> Delete job and all the builds in it
10021013
delete-build <job-id> <build-id> Delete build by id
@@ -1032,7 +1043,7 @@ def format_epilog(self, formatter):
10321043
"""
10331044
parser = MyParser(usage=usage, description=description, epilog=epilog, version="%s %s" % ("%prog", __version__))
10341045
parser.add_option("-k", "--apikey", dest="apikey",
1035-
help="API key - the API key for Testdroid Cloud. Optional. You can use environment variable TESTDROID_APIKEY as well.")
1046+
help="API key - the API key for Bitbar Cloud. Optional. You can use environment variable TESTDROID_APIKEY as well.")
10361047
parser.add_option("-u", "--username", dest="username",
10371048
help="Username - the email address. Optional. You can use environment variable TESTDROID_USERNAME as well.")
10381049
parser.add_option("-p", "--password", dest="password",

testdroid/tests/test_all.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_upload(self):
6969
url = '{}/{}'.format(URL_API, path)
7070
responses.add(responses.POST, url, json=JSON, status=200)
7171
response = t.upload(path, file_path)
72-
self.assertEqual(response.status_code, 200)
72+
self.assertEqual(response, JSON)
7373

7474
@responses.activate
7575
def test_get_me(self):
@@ -194,19 +194,20 @@ def test_start_test_run(self):
194194
'id': USER_ID,
195195
'name': 'Sample project',
196196
}
197+
197198
responses.add(responses.GET, url, json=json, status=200)
198199

199200
responses.add(responses.GET, URL_API_ME, json=json, status=200)
201+
200202
url = '{}/projects/{}/runs'.format(
201203
URL_USERS, PROJECT_ID)
202204
json = {
203205
'id': 12,
204206
'displayName': "My test run"
205207
}
206208

207-
208209
responses.add(responses.POST, url, json=json, status=201)
209-
self.assertEqual(t.start_test_run(PROJECT_ID, DEVICE_GROUP_ID), json['id'])
210+
self.assertEqual(t.start_test_run(PROJECT_ID, DEVICE_GROUP_ID), json['id'])
210211

211212
@responses.activate
212213
def test_delete_project_parameters(self):
@@ -216,9 +217,8 @@ def test_delete_project_parameters(self):
216217
json = {
217218
'id': USER_ID
218219
}
220+
219221
responses.add(responses.GET, URL_API_ME, json=json, status=200)
220222
responses.add(responses.DELETE, url, json=JSON, status=204)
221223
response = t.delete_project_parameters(PROJECT_ID, PARAM_ID)
222224
self.assertEqual(response.status_code, 204)
223-
224-

0 commit comments

Comments
 (0)