From ad371062e7ed162e8c6b20c970e13090dcea703a Mon Sep 17 00:00:00 2001 From: Remek Zajac Date: Tue, 16 Dec 2014 14:53:46 +0000 Subject: [PATCH] Adding the ability to change the project config (so that the client can set the project limitations, like narrow down the scope of tests to a specific package) --- testdroid/__init__.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/testdroid/__init__.py b/testdroid/__init__.py index fb3337b..bf23588 100755 --- a/testdroid/__init__.py +++ b/testdroid/__init__.py @@ -317,6 +317,18 @@ def set_project_parameters(self, project_id, parameters): path = "/users/%s/projects/%s/config/parameters" % ( me['id'], project_id ) reply = self.post(path=path, payload=parameters) + + """ Set project config according to http://docs.testdroid.com/_pages/client.html#project-config + """ + def set_project_config(self, project_id, payload): + #set the project config to reflect the given json payload + #e.g.: {'usedDeviceGroupId': 1234} + if isinstance(payload, str): + payload=json.loads(payload) + me = self.get_me() + path = "/users/%s/projects/%s/config" % ( me['id'], project_id ) + return self.post(path=path, payload=payload) + """ Start a test run on a device group """ def start_test_run(self, project_id, device_group_id=None, device_model_ids=None): @@ -337,8 +349,8 @@ def start_test_run(self, project_id, device_group_id=None, device_model_ids=None print "Device group %s not found" % device_group_id sys.exit(1) # Update device group - path = "/users/%s/projects/%s/config" % ( me['id'], project_id ) - reply = self.post(path=path, payload={'usedDeviceGroupId': device_group_id}) + + reply = self.set_project_config(project_id=project_id, payload={'usedDeviceGroupId': device_group_id}) if int(reply['usedDeviceGroupId']) != int(device_group_id): print "Unable to set used device group to %s for project %s" % (device_group_id, project_id) sys.exit(1) @@ -524,6 +536,10 @@ def format_epilog(self, formatter): upload-application Upload application to project upload-test Upload test file to project upload-data Upload additional data file to project + set-project-config Change the project config parameters as facilitated by the API: + http://docs.testdroid.com/_pages/client.html#project-config + e.g.: + ./testdroid-api-client set-project-config 1234 '{"limitationType":"CLASS", "limitationValue":"com.foo.test.VerifyFoo"}' start-test-run Start a test run start-wait-download-test-run Start a test run, await completion (polling) and @@ -535,7 +551,7 @@ def format_epilog(self, formatter): download-test-run Download test run data. Data will be downloaded to current directory in a structure: [test-run-id]/[device-run-id]-[device-name]/files... - download-test-screenshots + download-test-screenshots Download test run data. Data will be downloaded to current directory in a structure: [test-run-id]/[device-run-id]-[device-name]/files... @@ -564,6 +580,7 @@ def get_commands(self): "upload-application": self.upload_application_file, "upload-test": self.upload_test_file, "upload-data": self.upload_data_file, + "set-project-config": self.set_project_config, "start-test-run": self.start_test_run, "start-wait-download-test-run":self.start_wait_download_test_run, "wait-test-run":self.wait_test_run,