@@ -780,6 +780,195 @@ def test_find_archives_with_offset_and_count(self):
780
780
expect (list (archive_list .items )).to (have_length (4 ))
781
781
# TODO: we could inspect each item in the list
782
782
783
+ @httpretty .activate
784
+ def test_find_archives_with_sessionid (self ):
785
+ """ Test get_archives method using session_id parameter """
786
+ httpretty .register_uri (
787
+ httpretty .GET ,
788
+ u ('https://api.opentok.com/v2/project/{0}/archive' ).format (self .api_key ),
789
+ body = textwrap .dedent (u ("""\
790
+ {
791
+ "count" : 4,
792
+ "items" : [ {
793
+ "createdAt" : 1395187836000,
794
+ "duration" : 62,
795
+ "id" : "f6e7ee58-d6cf-4a59-896b-6d56b158ec71",
796
+ "name" : "",
797
+ "partnerId" : 123456,
798
+ "reason" : "",
799
+ "sessionId" : "SESSIONID",
800
+ "size" : 8347554,
801
+ "status" : "available",
802
+ "hasAudio": true,
803
+ "hasVideo": true,
804
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2Ff6e7ee58-d6cf-4a59-896b-6d56b158ec71%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
805
+ }, {
806
+ "createdAt" : 1395183243000,
807
+ "duration" : 544,
808
+ "id" : "30b3ebf1-ba36-4f5b-8def-6f70d9986fe9",
809
+ "name" : "",
810
+ "partnerId" : 123456,
811
+ "reason" : "",
812
+ "sessionId" : "SESSIONID",
813
+ "size" : 78499758,
814
+ "status" : "available",
815
+ "hasAudio": true,
816
+ "hasVideo": true,
817
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2F30b3ebf1-ba36-4f5b-8def-6f70d9986fe9%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
818
+ }, {
819
+ "createdAt" : 1394396753000,
820
+ "duration" : 24,
821
+ "id" : "b8f64de1-e218-4091-9544-4cbf369fc238",
822
+ "name" : "showtime again",
823
+ "partnerId" : 123456,
824
+ "reason" : "",
825
+ "sessionId" : "SESSIONID",
826
+ "size" : 2227849,
827
+ "status" : "available",
828
+ "hasAudio": true,
829
+ "hasVideo": true,
830
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2Fb8f64de1-e218-4091-9544-4cbf369fc238%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
831
+ }, {
832
+ "createdAt" : 1394321113000,
833
+ "duration" : 1294,
834
+ "id" : "832641bf-5dbf-41a1-ad94-fea213e59a92",
835
+ "name" : "showtime",
836
+ "partnerId" : 123456,
837
+ "reason" : "",
838
+ "sessionId" : "SESSIONID",
839
+ "size" : 42165242,
840
+ "status" : "available",
841
+ "hasAudio": true,
842
+ "hasVideo": true,
843
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2F832641bf-5dbf-41a1-ad94-fea213e59a92%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
844
+ }]
845
+ }""" )),
846
+ status = 200 ,
847
+ content_type = u ('application/json' ))
848
+
849
+ archive_list = self .opentok .get_archives (session_id = 'SESSIONID' )
850
+
851
+ validate_jwt_header (self , httpretty .last_request ().headers [u ('x-opentok-auth' )])
852
+ expect (httpretty .last_request ().headers [u ('user-agent' )]).to (contain (
853
+ u ('OpenTok-Python-SDK/' )+ __version__ ))
854
+ expect (httpretty .last_request ().headers [u ('content-type' )]).to (equal (u ('application/json' )))
855
+ expect (httpretty .last_request ()).to (have_property (u ('querystring' ), {
856
+ u ('sessionId' ): [u ('SESSIONID' )]
857
+ }))
858
+ expect (archive_list ).to (be_an (ArchiveList ))
859
+ expect (archive_list ).to (have_property (u ('count' ), 4 ))
860
+ expect (list (archive_list .items )).to (have_length (4 ))
861
+
862
+ @httpretty .activate
863
+ def test_find_archives_with_offset_count_sessionId (self ):
864
+ """ Test get_archives method using all parameters: offset, count and sessionId """
865
+ httpretty .register_uri (
866
+ httpretty .GET ,
867
+ u ('https://api.opentok.com/v2/project/{0}/archive' ).format (self .api_key ),
868
+ body = textwrap .dedent (u ("""\
869
+ {
870
+ "count" : 2,
871
+ "items" : [ {
872
+ "createdAt" : 1394396753000,
873
+ "duration" : 24,
874
+ "id" : "b8f64de1-e218-4091-9544-4cbf369fc238",
875
+ "name" : "showtime again",
876
+ "partnerId" : 123456,
877
+ "reason" : "",
878
+ "sessionId" : "SESSIONID",
879
+ "size" : 2227849,
880
+ "status" : "available",
881
+ "hasAudio": true,
882
+ "hasVideo": true,
883
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2Fb8f64de1-e218-4091-9544-4cbf369fc238%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
884
+ }, {
885
+ "createdAt" : 1394321113000,
886
+ "duration" : 1294,
887
+ "id" : "832641bf-5dbf-41a1-ad94-fea213e59a92",
888
+ "name" : "showtime",
889
+ "partnerId" : 123456,
890
+ "reason" : "",
891
+ "sessionId" : "SESSIONID",
892
+ "size" : 42165242,
893
+ "status" : "available",
894
+ "hasAudio": true,
895
+ "hasVideo": true,
896
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2F832641bf-5dbf-41a1-ad94-fea213e59a92%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
897
+ }]
898
+ }""" )),
899
+ status = 200 ,
900
+ content_type = u ('application/json' ))
901
+
902
+ archive_list = self .opentok .get_archives (offset = 2 , count = 2 , session_id = 'SESSIONID' )
903
+
904
+ validate_jwt_header (self , httpretty .last_request ().headers [u ('x-opentok-auth' )])
905
+ expect (httpretty .last_request ().headers [u ('user-agent' )]).to (contain (
906
+ u ('OpenTok-Python-SDK/' )+ __version__ ))
907
+ expect (httpretty .last_request ().headers [u ('content-type' )]).to (equal (u ('application/json' )))
908
+ expect (httpretty .last_request ()).to (have_property (u ('querystring' ), {
909
+ u ('offset' ): [u ('2' )],
910
+ u ('count' ): [u ('2' )],
911
+ u ('sessionId' ): [u ('SESSIONID' )]
912
+ }))
913
+ expect (archive_list ).to (be_an (ArchiveList ))
914
+ expect (archive_list ).to (have_property (u ('count' ), 2 ))
915
+ expect (list (archive_list .items )).to (have_length (2 ))
916
+
917
+ @httpretty .activate
918
+ def test_find_archives_alternative_method (self ):
919
+ """ Test list_archives method using all parameters: offset, count and sessionId """
920
+ httpretty .register_uri (
921
+ httpretty .GET ,
922
+ u ('https://api.opentok.com/v2/project/{0}/archive' ).format (self .api_key ),
923
+ body = textwrap .dedent (u ("""\
924
+ {
925
+ "count" : 2,
926
+ "items" : [ {
927
+ "createdAt" : 1394396753000,
928
+ "duration" : 24,
929
+ "id" : "b8f64de1-e218-4091-9544-4cbf369fc238",
930
+ "name" : "showtime again",
931
+ "partnerId" : 123456,
932
+ "reason" : "",
933
+ "sessionId" : "SESSIONID",
934
+ "size" : 2227849,
935
+ "status" : "available",
936
+ "hasAudio": true,
937
+ "hasVideo": true,
938
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2Fb8f64de1-e218-4091-9544-4cbf369fc238%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
939
+ }, {
940
+ "createdAt" : 1394321113000,
941
+ "duration" : 1294,
942
+ "id" : "832641bf-5dbf-41a1-ad94-fea213e59a92",
943
+ "name" : "showtime",
944
+ "partnerId" : 123456,
945
+ "reason" : "",
946
+ "sessionId" : "SESSIONID",
947
+ "size" : 42165242,
948
+ "status" : "available",
949
+ "hasAudio": true,
950
+ "hasVideo": true,
951
+ "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2F832641bf-5dbf-41a1-ad94-fea213e59a92%2Farchive.mp4?Expires=1395188695&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
952
+ }]
953
+ }""" )),
954
+ status = 200 ,
955
+ content_type = u ('application/json' ))
956
+
957
+ archive_list = self .opentok .list_archives (offset = 2 , count = 2 , session_id = 'SESSIONID' )
958
+
959
+ validate_jwt_header (self , httpretty .last_request ().headers [u ('x-opentok-auth' )])
960
+ expect (httpretty .last_request ().headers [u ('user-agent' )]).to (contain (
961
+ u ('OpenTok-Python-SDK/' )+ __version__ ))
962
+ expect (httpretty .last_request ().headers [u ('content-type' )]).to (equal (u ('application/json' )))
963
+ expect (httpretty .last_request ()).to (have_property (u ('querystring' ), {
964
+ u ('offset' ): [u ('2' )],
965
+ u ('count' ): [u ('2' )],
966
+ u ('sessionId' ): [u ('SESSIONID' )]
967
+ }))
968
+ expect (archive_list ).to (be_an (ArchiveList ))
969
+ expect (archive_list ).to (have_property (u ('count' ), 2 ))
970
+ expect (list (archive_list .items )).to (have_length (2 ))
971
+
783
972
@httpretty .activate
784
973
def test_find_paused_archive (self ):
785
974
archive_id = u ('f6e7ee58-d6cf-4a59-896b-6d56b158ec71' )
0 commit comments