@@ -569,32 +569,51 @@ def get_test_run(self, project_id, test_run_id):
569569
570570 return self .get ("me/projects/%s/runs/%s" % (project_id , test_run_id ))
571571
572- def retry_test_run (self , project_id , test_run_id , device_run_ids = None ):
573- """ Re-run an already-existing test run. Specify individual device run IDs to only re-run those devices. """
572+ def retry_test_run (self , project_id , test_run_id , device_session_ids = None ):
573+ """ Re-run an already-existing test run. Specify individual device session IDs to only re-run those devices. """
574574
575575 endpoint = "me/projects/%s/runs/%s/retry" % (project_id , test_run_id )
576- if device_run_ids :
577- endpoint += "?deviceRunIds[]=" + "&deviceRunIds[]=" .join (str (device_id ) for device_id in device_run_ids )
576+ if device_session_ids :
577+ endpoint += "?deviceRunIds[]=" + "&deviceRunIds[]=" .join (str (device_id ) for device_id in device_session_ids )
578578 return self .post (endpoint )
579579
580580 def abort_test_run (self , project_id , test_run_id ):
581581 """ Abort a test run """
582582
583583 return self .post ("me/projects/%s/runs/%s/abort" % (project_id , test_run_id ))
584584
585+ def get_device_sessions (self , project_id , test_run_id , limit = 0 ):
586+ """ Return device sessions for a project """
587+
588+ return self .get (path = "me/projects/%s/runs/%s/device-sessions" %
589+ (project_id , test_run_id ), payload = {'limit' : limit })
590+
585591 def get_device_runs (self , project_id , test_run_id , limit = 0 ):
586- """ Return device runs for a project """
592+ """ ***DEPRECATED***
593+
594+ Return device sessions for a project
595+ use get_device_sessions() instead
596+ """
587597
588- return self .get (path = "me/projects/%s/runs/%s/device-runs" % (project_id , test_run_id ), payload = {'limit' : limit })
598+ return self .get_device_sessions (project_id , test_run_id , limit )
599+
600+ def get_device_session_screenshots_list (self , project_id , test_run_id , device_session_id , limit = 0 ):
601+ """ Downloads screenshots list for a device session """
602+
603+ return self .get ("me/projects/%s/runs/%s/device-sessions/%s/screenshots" %
604+ (project_id , test_run_id , device_session_id ), payload = {'limit' : limit })
589605
590606 def get_device_run_screenshots_list (self , project_id , test_run_id , device_run_id , limit = 0 ):
591- """ Downloads screenshots list for a device run """
607+ """ ***DEPRECATED***
592608
593- return self .get ("me/projects/%s/runs/%s/device-runs/%s/screenshots" % (project_id , test_run_id , device_run_id ),
594- payload = {'limit' : limit })
609+ Downloads screenshots list for a device run
610+ use get_device_run_screenshots_list() instead
611+ """
595612
596- def get_device_run_files (self , project_id , test_run_id , device_session_id , tags = None ):
597- """ Get list of files for device run """
613+ return self .get_device_session_screenshots_list (project_id , test_run_id , device_run_id , limit )
614+
615+ def get_device_session_files (self , project_id , test_run_id , device_session_id , tags = None ):
616+ """ Get list of files for device session """
598617
599618 if tags is None :
600619 return self .get ("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files" %
@@ -603,6 +622,15 @@ def get_device_run_files(self, project_id, test_run_id, device_session_id, tags=
603622 return self .get ("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files?tag[]=%s" %
604623 (project_id , test_run_id , device_session_id , tags ))
605624
625+ def get_device_run_files (self , project_id , test_run_id , device_session_id , tags = None ):
626+ """ ***DEPRECATED***
627+
628+ Get list of files for device run
629+ use get_device_session_files() instead
630+ """
631+
632+ return self .get_device_session_files (project_id , test_run_id , device_session_id , tags )
633+
606634 def get_input_files (self , limit = 0 ):
607635 """ Get list of input files """
608636
@@ -612,25 +640,25 @@ def download_test_run(self, project_id, test_run_id):
612640 """ Downloads test run files to a directory hierarchy """
613641
614642 test_run = self .get_test_run (project_id , test_run_id )
615- device_runs = self .get_device_runs (project_id , test_run_id )
643+ device_sessions = self .get_device_sessions (project_id , test_run_id )
616644
617645 logger .info ("" )
618- logger .info ("Test run %s: \" %s\" has %s device runs :" %
619- (test_run ['id' ], test_run ['displayName' ], len (device_runs ['data' ])))
646+ logger .info ("Test run %s: \" %s\" has %s device sessions :" %
647+ (test_run ['id' ], test_run ['displayName' ], len (device_sessions ['data' ])))
620648
621- for device_run in device_runs ['data' ]:
622- state = device_run ['state' ]
649+ for device_session in device_sessions ['data' ]:
650+ state = device_session ['state' ]
623651 logger .info ("" )
624- logger .info ("%s \" %s\" %s" % (device_run ['id' ], device_run ['device' ]['displayName' ], state ))
652+ logger .info ("%s \" %s\" %s" % (device_session ['id' ], device_session ['device' ]['displayName' ], state ))
625653
626654 if state in ("ABORTED" , "TIMEOUT" , "WARNING" , "SUCCEEDED" , "FAILED" , "EXCLUDED" ):
627- directory = "%s-%s/%d-%s" % (test_run_id , test_run ['displayName' ], device_run ['id' ],
628- device_run ['device' ]['displayName' ])
629- session_id = device_run ['id' ]
630- files = self .get_device_run_files (project_id , test_run_id , session_id )
655+ directory = "%s-%s/%d-%s" % (test_run_id , test_run ['displayName' ], device_session ['id' ],
656+ device_session ['device' ]['displayName' ])
657+ session_id = device_session ['id' ]
658+ files = self .get_device_session_files (project_id , test_run_id , session_id )
631659 self .__download_files (files , directory )
632660 else :
633- logger .info ("Device run is not ended - Skipping file downloads" )
661+ logger .info ("Device session hasn't ended - Skipping file downloads" )
634662 logger .info ("" )
635663
636664 def __download_files (self , files , directory ):
@@ -654,18 +682,19 @@ def download_test_screenshots(self, project_id, test_run_id):
654682 """ Downloads test run screenshots """
655683
656684 test_run = self .get_test_run (project_id , test_run_id )
657- device_runs = self .get_device_runs (project_id , test_run_id )
658- logger .info ("Test run %s: \" %s\" has %s device runs:" %
659- (test_run ['id' ], test_run ['displayName' ], len (device_runs ['data' ])))
660- for device_run in device_runs ['data' ]:
661- logger .info ("%s \" %s\" %s" % (device_run ['id' ], device_run ['device' ]['displayName' ], device_run ['state' ]))
685+ device_sessions = self .get_device_sessions (project_id , test_run_id )
686+ logger .info ("Test run %s: \" %s\" has %s device sessions:" %
687+ (test_run ['id' ], test_run ['displayName' ], len (device_sessions ['data' ])))
688+ for device_session in device_sessions ['data' ]:
689+ logger .info ("%s \" %s\" %s" %
690+ (device_session ['id' ], device_session ['device' ]['displayName' ], device_session ['state' ]))
662691
663692 logger .info ("" )
664- for device_run in device_runs ['data' ]:
665- if device_run ['state' ] in ["SUCCEEDED" , "FAILED" , "ABORTED" , "WARNING" , "TIMEOUT" ]:
693+ for device_session in device_sessions ['data' ]:
694+ if device_session ['state' ] in ["SUCCEEDED" , "FAILED" , "ABORTED" , "WARNING" , "TIMEOUT" ]:
666695 directory = "%s-%s/%d-%s/screenshots" % (test_run ['id' ], test_run ['displayName' ],
667- device_run ['id' ], device_run ['device' ]['displayName' ])
668- screenshots = self .get_device_run_screenshots_list (project_id , test_run_id , device_run ['id' ])
696+ device_session ['id' ], device_session ['device' ]['displayName' ])
697+ screenshots = self .get_device_session_screenshots_list (project_id , test_run_id , device_session ['id' ])
669698 no_screenshots = True
670699
671700 for screenshot in screenshots ['data' ]:
@@ -675,7 +704,7 @@ def download_test_screenshots(self, project_id, test_run_id):
675704 os .makedirs (directory )
676705
677706 if not os .path .exists (full_path ):
678- self .__download_screenshot (project_id , test_run ['id' ], device_run ['id' ], screenshot ['id' ],
707+ self .__download_screenshot (project_id , test_run ['id' ], device_session ['id' ], screenshot ['id' ],
679708 full_path )
680709 else :
681710 ''' Earlier downloaded images are checked, and if needed re-downloaded.
@@ -686,18 +715,18 @@ def download_test_screenshots(self, project_id, test_run_id):
686715 else :
687716 raise
688717 except :
689- self .__download_screenshot (project_id , test_run ['id' ], device_run [ 'id' ], screenshot ['id' ],
690- full_path )
718+ self .__download_screenshot (project_id , test_run ['id' ], device_session ['id' ],
719+ screenshot [ 'id' ], full_path )
691720
692721 if no_screenshots :
693- logger .info ("Device %s has no screenshots - skipping" % device_run ['device' ]['displayName' ])
722+ logger .info ("Device %s has no screenshots - skipping" % device_session ['device' ]['displayName' ])
694723 else :
695724 logger .info ("Device %s has errored or has not finished - skipping" %
696- device_run ['device' ]['displayName' ])
725+ device_session ['device' ]['displayName' ])
697726
698- def __download_screenshot (self , project_id , test_run_id , device_run_id , screenshot_id , full_path ):
699- url = "me/projects/%s/runs/%s/device-runs /%s/screenshots/%s" % \
700- (project_id , test_run_id , device_run_id , screenshot_id )
727+ def __download_screenshot (self , project_id , test_run_id , device_session_id , screenshot_id , full_path ):
728+ url = "me/projects/%s/runs/%s/device-sessions /%s/screenshots/%s" % \
729+ (project_id , test_run_id , device_session_id , screenshot_id )
701730 prog = DownloadProgressBar ()
702731 self .download (url , full_path , callback = lambda pos , total : prog .update (int (pos ), int (total )))
703732 print ("" )
@@ -740,7 +769,7 @@ def get_access_group_resources(self, access_group_id):
740769 def get_access_group_resource (self , access_group_id , resource_id ):
741770 """ Get resource from access group """
742771
743- return self .get ("ame/ccess -groups/{}/resources/{}" .format (access_group_id , resource_id ))
772+ return self .get ("me/access -groups/{}/resources/{}" .format (access_group_id , resource_id ))
744773
745774 def delete_access_group_resource (self , access_group_id , resource_id ):
746775 """ Delete resource from access group """
@@ -795,7 +824,6 @@ def format_epilog(self, formatter):
795824 usage = "usage: %prog [options] <command> [arguments...]"
796825 description = "Client for Bitbar Cloud API v2"
797826 epilog = """
798-
799827Commands:
800828
801829 me Get user details
@@ -824,15 +852,17 @@ def format_epilog(self, formatter):
824852 wait-test-run <project-id> <test-run-id> Await completion (polling) of the test run
825853 test-runs <project-id> Get test runs for a project
826854 test-run <project-id> <test-run-id> Get test run details
827- device-runs <project-id> <test-run-id> Get device runs for a test run
855+ get_device_sessions <project-id> <test-run-id>
856+ Get device sessions for a test run
857+ device-runs <project-id> <test-run-id> ***DEPRECATED*** Get device runs for a test run
828858 download-test-run <project-id> <test-run-id>
829859 Download test run data. Data will be downloaded to
830860 current directory in a structure:
831- [test-run-id]/[device-run -id]-[device-name]/files...
861+ [test-run-id]/[device-session -id]-[device-name]/files...
832862 download-test-screenshots <project-id> <test-run-id>
833863 Download test run screenshots. Screenshots will be downloaded to
834864 current directory in a structure:
835- [test-run-id]/[device-run -id]-[device-name]/screenshots/...
865+ [test-run-id]/[device-session -id]-[device-name]/screenshots/...
836866
837867 access-groups Get access groups
838868 access-group <access-group-id> Get an access group by id
@@ -901,6 +931,8 @@ def get_commands(self):
901931 "wait-test-run" : self .wait_test_run ,
902932 "test-run" : self .get_test_run ,
903933 "test-runs" : self .print_project_test_runs ,
934+ "device-sessions" : self .get_device_sessions ,
935+ "device-session-files" : self .get_device_session_files ,
904936 "device-runs" : self .get_device_runs ,
905937 "device-run-files" : self .get_device_run_files ,
906938 "list-input-files" : self .print_input_files ,
0 commit comments