|
9 | 9 | import pytz |
10 | 10 | from .validate_jwt import validate_jwt_header |
11 | 11 |
|
12 | | -from opentok import OpenTok, Archive, ArchiveList, OutputModes, OpenTokException, __version__ |
| 12 | +from opentok import ( |
| 13 | + OpenTok, |
| 14 | + Archive, |
| 15 | + ArchiveList, |
| 16 | + OutputModes, |
| 17 | + OpenTokException, |
| 18 | + __version__, |
| 19 | + ArchiveError |
| 20 | +) |
13 | 21 |
|
14 | 22 | class OpenTokArchiveApiTest(unittest.TestCase): |
15 | 23 | def setUp(self): |
@@ -1049,3 +1057,73 @@ def test_find_archive_with_unknown_properties(self): |
1049 | 1057 | archive = self.opentok.get_archive(archive_id) |
1050 | 1058 |
|
1051 | 1059 | expect(archive).to(be_an(Archive)) |
| 1060 | + |
| 1061 | + @httpretty.activate |
| 1062 | + def test_set_archive_layout(self): |
| 1063 | + """ Test set archive layout functionality """ |
| 1064 | + archive_id = u('f6e7ee58-d6cf-4a59-896b-6d56b158ec71') |
| 1065 | + |
| 1066 | + httpretty.register_uri( |
| 1067 | + httpretty.PUT, |
| 1068 | + u('https://api.opentok.com/v2/project/{0}/archive/{1}/layout').format( |
| 1069 | + self.api_key, |
| 1070 | + archive_id |
| 1071 | + ), |
| 1072 | + status=200, |
| 1073 | + content_type=u('application/json') |
| 1074 | + ) |
| 1075 | + |
| 1076 | + self.opentok.set_archive_layout(archive_id, 'horizontalPresentation') |
| 1077 | + |
| 1078 | + validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')]) |
| 1079 | + expect(httpretty.last_request().headers[u('user-agent')]).to(contain( |
| 1080 | + u('OpenTok-Python-SDK/')+__version__)) |
| 1081 | + expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json'))) |
| 1082 | + |
| 1083 | + @httpretty.activate |
| 1084 | + def test_set_custom_archive_layout(self): |
| 1085 | + """ Test set a custom archive layout specifying the 'stylesheet' parameter """ |
| 1086 | + archive_id = u('f6e7ee58-d6cf-4a59-896b-6d56b158ec71') |
| 1087 | + |
| 1088 | + httpretty.register_uri( |
| 1089 | + httpretty.PUT, |
| 1090 | + u('https://api.opentok.com/v2/project/{0}/archive/{1}/layout').format( |
| 1091 | + self.api_key, |
| 1092 | + archive_id |
| 1093 | + ), |
| 1094 | + status=200, |
| 1095 | + content_type=u('application/json') |
| 1096 | + ) |
| 1097 | + |
| 1098 | + self.opentok.set_archive_layout( |
| 1099 | + archive_id, |
| 1100 | + 'custom', |
| 1101 | + 'stream.instructor {position: absolute; width: 100%; height:50%;}' |
| 1102 | + ) |
| 1103 | + |
| 1104 | + validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')]) |
| 1105 | + expect(httpretty.last_request().headers[u('user-agent')]).to(contain( |
| 1106 | + u('OpenTok-Python-SDK/')+__version__)) |
| 1107 | + expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json'))) |
| 1108 | + |
| 1109 | + @httpretty.activate |
| 1110 | + def test_set_archive_layout_throws_exception(self): |
| 1111 | + """ Test invalid request in set archive layout """ |
| 1112 | + archive_id = u('f6e7ee58-d6cf-4a59-896b-6d56b158ec71') |
| 1113 | + |
| 1114 | + httpretty.register_uri( |
| 1115 | + httpretty.PUT, |
| 1116 | + u('https://api.opentok.com/v2/project/{0}/archive/{1}/layout').format( |
| 1117 | + self.api_key, |
| 1118 | + archive_id |
| 1119 | + ), |
| 1120 | + status=400, |
| 1121 | + content_type=u('application/json') |
| 1122 | + ) |
| 1123 | + |
| 1124 | + self.assertRaises( |
| 1125 | + ArchiveError, |
| 1126 | + self.opentok.set_archive_layout, |
| 1127 | + archive_id, |
| 1128 | + 'horizontalPresentation' |
| 1129 | + ) |
0 commit comments