|
11 | 11 | from optparse import OptionParser
|
12 | 12 | from datetime import datetime
|
13 | 13 |
|
14 |
| -__version__ = '2.42.1' |
| 14 | +__version__ = '2.43.1' |
15 | 15 |
|
16 | 16 | FORMAT = "%(message)s"
|
17 | 17 | logging.basicConfig(format=FORMAT)
|
@@ -80,7 +80,7 @@ def update(self, pos, total):
|
80 | 80 | else:
|
81 | 81 | self.prog_bar += ' '
|
82 | 82 | if sys.platform.lower().startswith('win'):
|
83 |
| - print(self +'\r') |
| 83 | + print(str(self) + '\r') |
84 | 84 | else:
|
85 | 85 | print(str(self) + chr(27) + '[A')
|
86 | 86 |
|
@@ -240,7 +240,6 @@ def upload(self, path=None, filename=None):
|
240 | 240 | res = requests.post(url, files=files, headers=self._build_headers())
|
241 | 241 | if res.status_code not in list(range(200, 300)):
|
242 | 242 | raise RequestResponseError(res.text, res.status_code)
|
243 |
| - print(res) |
244 | 243 | return res
|
245 | 244 |
|
246 | 245 | """ GET from API resource
|
@@ -399,6 +398,14 @@ def upload_application_file(self, project_id, filename):
|
399 | 398 | path = "users/%s/projects/%s/files/application" % (me['id'], project_id)
|
400 | 399 | self.upload(path=path, filename=filename)
|
401 | 400 |
|
| 401 | + """ Upload application file to project |
| 402 | + """ |
| 403 | + def upload_file(self, filename): |
| 404 | + me = self.get_me() |
| 405 | + 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 | + |
402 | 409 | """ Upload test file to project
|
403 | 410 | """
|
404 | 411 | def upload_test_file(self, project_id, filename):
|
@@ -591,6 +598,14 @@ def print_project_test_runs(self, project_id, limit=0):
|
591 | 598 | def get_test_run(self, project_id, test_run_id):
|
592 | 599 | return self.get("me/projects/%s/runs/%s" % (project_id, test_run_id))
|
593 | 600 |
|
| 601 | + """ Re-run an already-existing test run. Specify individual device run IDs to only re-run those devices. |
| 602 | + """ |
| 603 | + def retry_test_run(self, project_id, test_run_id, device_run_ids=[]): |
| 604 | + endpoint = "me/projects/%s/runs/%s/retry" % (project_id, test_run_id) |
| 605 | + if device_run_ids: |
| 606 | + endpoint += "?deviceRunIds[]=" + "&deviceRunIds[]=".join(str(device_id) for device_id in device_run_ids) |
| 607 | + return self.post(endpoint) |
| 608 | + |
594 | 609 | """Abort a test run
|
595 | 610 | """
|
596 | 611 | def abort_test_run(self, project_id, test_run_id):
|
@@ -667,27 +682,45 @@ def create_job(self, job_name, content, job_type="BUILD"):
|
667 | 682 | return job
|
668 | 683 |
|
669 | 684 | """ Create a build
|
670 |
| - """ |
671 |
| - def create_build(self, job_id, file_id=None): |
672 |
| - build = self.post(path="me/jobs/{}/builds".format(job_id), payload={"fileId": file_id}) |
673 |
| - print(build) |
674 |
| - |
| 685 | + build_config: |
| 686 | + fileId: int |
| 687 | + executorId: int |
| 688 | + configuration: String |
| 689 | + resultsConfig: [resultsConfig] |
| 690 | +
|
| 691 | + resultsConfig: |
| 692 | + sourceName |
| 693 | + destinationName |
| 694 | + isDirectory |
| 695 | + fileUrlEnvVariable |
| 696 | +
|
| 697 | + usage: client.create_build(job_id, json.dumps({"fileId":123213...)) |
| 698 | + """ |
| 699 | + def create_build(self, job_id, build_config={}): |
| 700 | + build = self.post(path="me/jobs/{}/builds".format(job_id), payload=build_config, headers={'Content-type': 'application/json', 'Accept': 'application/json'}) |
675 | 701 | logger.info("build %s: %s (%s) " % (build['id'], build['buildNumber'], build['state'] ))
|
676 | 702 | return build
|
677 | 703 |
|
| 704 | + """ Update job |
| 705 | + """ |
| 706 | + def upload_job(self, job_id,job_name, content): |
| 707 | + job = self.post(path="me/jobs/{}".format(job_id), payload={"name": job_name, "content": content}) |
| 708 | + |
| 709 | + logger.info("Job %s: %s (%s) created" % (job['id'], job['name'], job['type'] )) |
| 710 | + return job |
| 711 | + |
678 | 712 | """ Update job
|
679 | 713 | """
|
680 | 714 | def update_job(self, job_id,job_name, content):
|
681 | 715 | job = self.post(path="me/jobs/{}".format(job_id), payload={"name": job_name, "content": content})
|
682 |
| - print(job) |
683 | 716 |
|
684 | 717 | logger.info("Job %s: %s (%s) created" % (job['id'], job['name'], job['type'] ))
|
685 | 718 | return job
|
686 | 719 |
|
687 | 720 | """ Delete job
|
688 | 721 | """
|
689 | 722 | def delete_job(self, job_id):
|
690 |
| - return self.delete("me/jobs/{}".format(limit)) |
| 723 | + return self.delete("me/jobs/{}".format(job_id)) |
691 | 724 |
|
692 | 725 | """ Delete build
|
693 | 726 | """
|
@@ -824,6 +857,7 @@ def format_epilog(self, formatter):
|
824 | 857 | upload-application <project-id> <filename> Upload application to project
|
825 | 858 | upload-test <project-id> <filename> Upload test file to project
|
826 | 859 | upload-data <project-id> <filename> Upload additional data file to project
|
| 860 | + upload-file <filename> Upload to "Files" |
827 | 861 | set-project-config <project-id> <config-json>
|
828 | 862 | Change the project config parameters as facilitated by the API:
|
829 | 863 | http://docs.testdroid.com/_pages/client.html#project-config
|
@@ -876,6 +910,7 @@ def get_commands(self):
|
876 | 910 | "upload-application": self.upload_application_file,
|
877 | 911 | "upload-test": self.upload_test_file,
|
878 | 912 | "upload-data": self.upload_data_file,
|
| 913 | + "upload-file": self.upload_file, |
879 | 914 | "set-project-config": self.set_project_config,
|
880 | 915 | "start-test-run": self.start_test_run,
|
881 | 916 | "start-test-run-using-config": self.start_test_run_using_config,
|
|
0 commit comments