@@ -569,32 +569,51 @@ def get_test_run(self, project_id, test_run_id):
569
569
570
570
return self .get ("me/projects/%s/runs/%s" % (project_id , test_run_id ))
571
571
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. """
574
574
575
575
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 )
578
578
return self .post (endpoint )
579
579
580
580
def abort_test_run (self , project_id , test_run_id ):
581
581
""" Abort a test run """
582
582
583
583
return self .post ("me/projects/%s/runs/%s/abort" % (project_id , test_run_id ))
584
584
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
+
585
591
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
+ """
587
597
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 })
589
605
590
606
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***
592
608
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
+ """
595
612
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 """
598
617
599
618
if tags is None :
600
619
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=
603
622
return self .get ("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files?tag[]=%s" %
604
623
(project_id , test_run_id , device_session_id , tags ))
605
624
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
+
606
634
def get_input_files (self , limit = 0 ):
607
635
""" Get list of input files """
608
636
@@ -612,25 +640,25 @@ def download_test_run(self, project_id, test_run_id):
612
640
""" Downloads test run files to a directory hierarchy """
613
641
614
642
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 )
616
644
617
645
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' ])))
620
648
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' ]
623
651
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 ))
625
653
626
654
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 )
631
659
self .__download_files (files , directory )
632
660
else :
633
- logger .info ("Device run is not ended - Skipping file downloads" )
661
+ logger .info ("Device session hasn't ended - Skipping file downloads" )
634
662
logger .info ("" )
635
663
636
664
def __download_files (self , files , directory ):
@@ -654,18 +682,19 @@ def download_test_screenshots(self, project_id, test_run_id):
654
682
""" Downloads test run screenshots """
655
683
656
684
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' ]))
662
691
663
692
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" ]:
666
695
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' ])
669
698
no_screenshots = True
670
699
671
700
for screenshot in screenshots ['data' ]:
@@ -675,7 +704,7 @@ def download_test_screenshots(self, project_id, test_run_id):
675
704
os .makedirs (directory )
676
705
677
706
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' ],
679
708
full_path )
680
709
else :
681
710
''' Earlier downloaded images are checked, and if needed re-downloaded.
@@ -686,18 +715,18 @@ def download_test_screenshots(self, project_id, test_run_id):
686
715
else :
687
716
raise
688
717
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 )
691
720
692
721
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' ])
694
723
else :
695
724
logger .info ("Device %s has errored or has not finished - skipping" %
696
- device_run ['device' ]['displayName' ])
725
+ device_session ['device' ]['displayName' ])
697
726
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 )
701
730
prog = DownloadProgressBar ()
702
731
self .download (url , full_path , callback = lambda pos , total : prog .update (int (pos ), int (total )))
703
732
print ("" )
@@ -740,7 +769,7 @@ def get_access_group_resources(self, access_group_id):
740
769
def get_access_group_resource (self , access_group_id , resource_id ):
741
770
""" Get resource from access group """
742
771
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 ))
744
773
745
774
def delete_access_group_resource (self , access_group_id , resource_id ):
746
775
""" Delete resource from access group """
@@ -795,7 +824,6 @@ def format_epilog(self, formatter):
795
824
usage = "usage: %prog [options] <command> [arguments...]"
796
825
description = "Client for Bitbar Cloud API v2"
797
826
epilog = """
798
-
799
827
Commands:
800
828
801
829
me Get user details
@@ -824,15 +852,17 @@ def format_epilog(self, formatter):
824
852
wait-test-run <project-id> <test-run-id> Await completion (polling) of the test run
825
853
test-runs <project-id> Get test runs for a project
826
854
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
828
858
download-test-run <project-id> <test-run-id>
829
859
Download test run data. Data will be downloaded to
830
860
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...
832
862
download-test-screenshots <project-id> <test-run-id>
833
863
Download test run screenshots. Screenshots will be downloaded to
834
864
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/...
836
866
837
867
access-groups Get access groups
838
868
access-group <access-group-id> Get an access group by id
@@ -901,6 +931,8 @@ def get_commands(self):
901
931
"wait-test-run" : self .wait_test_run ,
902
932
"test-run" : self .get_test_run ,
903
933
"test-runs" : self .print_project_test_runs ,
934
+ "device-sessions" : self .get_device_sessions ,
935
+ "device-session-files" : self .get_device_session_files ,
904
936
"device-runs" : self .get_device_runs ,
905
937
"device-run-files" : self .get_device_run_files ,
906
938
"list-input-files" : self .print_input_files ,
0 commit comments