Skip to content

Commit 030c2d6

Browse files
author
Sakari Rautiainen
committed
Merge branch 'new_functions' into devel
2 parents 93910fb + 469cb77 commit 030c2d6

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

testdroid/__init__.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,28 @@ def get_me(self):
277277
def get_device_groups(self, limit=0):
278278
return self.get("me/device-groups", payload = {'limit': limit})
279279

280+
""" Returns list of frameworks
281+
"""
282+
def get_frameworks(self, limit=0):
283+
return self.get("me/available-frameworks", payload = {'limit': limit})
284+
285+
""" Returns list of project types
286+
"""
287+
def get_project_types(self, limit=0):
288+
return self.get("me/available-project-types", payload = {'limit': limit})
289+
280290
""" Returns list of devices
281291
"""
282292
def get_devices(self, limit=0):
283293
return self.get(path = "devices", payload = {'limit': limit})
284294

295+
296+
""" Print input files
297+
"""
298+
def print_input_files(self, limit=0):
299+
for input_file in self.get_input_files(limit)['data']:
300+
print("id:{} name:{} size:{} type:{}".format(input_file['id'],input_file['name'],input_file['size'],input_file['inputType']))
301+
285302
""" Print device groups
286303
"""
287304
def print_device_groups(self, limit=0):
@@ -300,6 +317,25 @@ def print_available_free_android_devices(self, limit=0):
300317
print device['displayName']
301318

302319
print ""
320+
321+
""" Print available frameworks
322+
"""
323+
def print_available_frameworks(self, os_type=None, limit=0):
324+
print ""
325+
print "Available frameworks"
326+
print "------------------------------"
327+
for framework in self.get_frameworks(limit)['data']:
328+
print("id: {}\tosType:{}\tname:{}".format(framework['id'], framework['osType'], framework['name']))
329+
330+
""" Print available project type
331+
"""
332+
def print_available_project_types(self, os_type=None, limit=0):
333+
print ""
334+
print "Available project types"
335+
print "------------------------------"
336+
for project_type in self.get_project_types(limit)['items']:
337+
print("name:{}".format(project_type))
338+
303339

304340
""" Print available free iOS devices
305341
"""
@@ -423,6 +459,28 @@ def set_project_framework(self, project_id, frameworkId):
423459
}
424460
self.post(path, payload={"frameworkId": frameworkId})
425461

462+
463+
""" Start a test run using test run config
464+
e.g '{"frameworkId":12252,
465+
"osType": "ANDROID",
466+
"projectId":1234,
467+
"files":[{"id":9876}, {"id":5432}]
468+
"testRunParameters":[{"key":"xyz", "value":"abc"}],
469+
"deviceGroupId":6854
470+
}'
471+
client.start_test_run_using_config(json.dumps({"frameworkId":123213}))
472+
"""
473+
def start_test_run_using_config(self, test_run_config={}):
474+
if type(test_run_config) == str:
475+
payload = json.loads(test_run_config)
476+
else:
477+
payload = test_run_config
478+
479+
me = self.get_me()
480+
path = "users/%s/runs" % (me['id'])
481+
test_run = self.post(path=path, payload=test_run_config, headers={'Content-type': 'application/json', 'Accept': 'application/json'})
482+
return test_run
483+
426484
""" Start a test run on a device group
427485
"""
428486
def start_test_run(self, project_id, device_group_id=None, device_model_ids=None, name=None, additional_params={}):
@@ -557,6 +615,11 @@ def get_device_run_files(self, project_id, test_run_id, device_session_id, tags=
557615
else:
558616
return self.get("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files?tag[]=%s" % (project_id, test_run_id, device_session_id, tags))
559617

618+
""" Get list of input files
619+
"""
620+
def get_input_files(self, limit=0):
621+
return self.get("me/files?limit={}&filter=s_direction_eq_INPUT".format(limit))
622+
560623
""" Downloads test run files to a directory hierarchy
561624
"""
562625
def download_test_run(self, project_id, test_run_id):
@@ -714,6 +777,8 @@ def get_commands(self):
714777
"me": self.get_me,
715778
"device-groups": self.print_device_groups,
716779
"available-free-devices": self.print_available_free_devices,
780+
"available-frameworks": self.print_available_frameworks,
781+
"available-project-types": self.print_available_project_types,
717782
"projects": self.print_projects,
718783
"create-project": self.create_project,
719784
"delete-project": self.delete_project,
@@ -722,12 +787,14 @@ def get_commands(self):
722787
"upload-data": self.upload_data_file,
723788
"set-project-config": self.set_project_config,
724789
"start-test-run": self.start_test_run,
790+
"start-test-run-using-config": self.start_test_run_using_config,
725791
"start-wait-download-test-run":self.start_wait_download_test_run,
726792
"wait-test-run":self.wait_test_run,
727793
"test-run": self.get_test_run,
728794
"test-runs": self.print_project_test_runs,
729795
"device-runs": self.get_device_runs,
730796
"device-run-files": self.get_device_run_files,
797+
"list-input-files": self.print_input_files,
731798
"download-test-run": self.download_test_run,
732799
"download-test-screenshots": self.download_test_screenshots
733800
}

0 commit comments

Comments
 (0)