Skip to content

Commit 8167431

Browse files
author
Sakari Rautiainen
committed
2 parents c09b565 + e503ce5 commit 8167431

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.6.2
2+
* Fixes: Init overloading fixed, api key usage for delete and posts
3+
* Features: Get project config.
14
2.6.1
25
* Added ability to set project framework
36
2.6.0

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.6.1'
6+
version = '2.6.2'
77

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

testdroid/__init__.py

Lines changed: 15 additions & 21 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.6.1'
8+
__version__ = '2.6.2'
99

1010
FORMAT = "%(message)s"
1111
logging.basicConfig(format=FORMAT)
@@ -100,25 +100,14 @@ class Testdroid:
100100
# polling interval when awaiting for test run completion
101101
polling_interval_mins = 10
102102

103-
""" Simple constructor, defaults against cloud.testdroid.com
103+
""" Constructor, defaults against cloud.testdroid.com
104104
"""
105-
def __init__(self):
106-
self.cloud_url="https://cloud.testdroid.com"
107-
108-
""" Full constructor with username and password
109-
"""
110-
def __init__(self, username=None, password=None, url="https://cloud.testdroid.com", download_buffer_size=65536):
111-
self.username = username
112-
self.password = password
113-
self.cloud_url = url
114-
self.download_buffer_size = download_buffer_size
115-
116-
""" Full constructor with api key
117-
"""
118-
def __init__(self, apikey=None, url="https://cloud.testdroid.com", download_buffer_size=65536):
119-
self.api_key = apikey
120-
self.cloud_url = url
121-
self.download_buffer_size = download_buffer_size
105+
def __init__(self, **kwargs):
106+
self.api_key = kwargs.get('apikey')
107+
self.username = kwargs.get('username')
108+
self.password = kwargs.get('password')
109+
self.cloud_url = kwargs.get('url') or "https://cloud.testdroid.com"
110+
self.download_buffer_size = kwargs.get('download_buffer_size') or 65536
122111

123112
def set_apikey(self, apikey):
124113
self.api_key = apikey
@@ -263,7 +252,7 @@ def get(self, path=None, payload={}, headers={}):
263252
"""
264253
def post(self, path=None, payload=None, headers={}):
265254
headers = dict(self._build_headers().items() + headers.items())
266-
url = "%s/api/v2/%s?access_token=%s" % (self.cloud_url, path, self.get_token())
255+
url = "%s/api/v2/%s" % (self.cloud_url, path)
267256
res = requests.post(url, payload, headers=headers)
268257
if res.status_code not in range(200, 300):
269258
raise RequestResponseError(res.text, res.status_code)
@@ -273,7 +262,7 @@ def post(self, path=None, payload=None, headers={}):
273262
"""
274263
def delete(self, path=None, payload=None, headers={}):
275264
headers = dict(self._build_headers().items() + headers.items())
276-
url = "%s/api/v2/%s?access_token=%s" % (self.cloud_url, path, self.get_token())
265+
url = "%s/api/v2/%s" % (self.cloud_url, path)
277266
res = requests.delete(url, headers=headers)
278267
if res.status_code not in range(200, 300):
279268
raise RequestResponseError(res.text, res.status_code)
@@ -409,6 +398,11 @@ def set_project_parameters(self, project_id, parameters):
409398
path = "/users/%s/projects/%s/config/parameters" % ( me['id'], project_id )
410399
return self.post(path=path, payload=parameters)
411400

401+
""" Get project config
402+
"""
403+
def get_project_config(self, project_id):
404+
path = "/me/projects/%s/config" % ( project_id )
405+
return self.get(path=path)
412406

413407
""" Set project config according to http://docs.testdroid.com/_pages/client.html#project-config
414408
"""

0 commit comments

Comments
 (0)