diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-28 11:14:26 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 07b1a18aa678d260009a93e36606c5c5f585723d (patch) | |
tree | 27a399fa0f7a29a7ac1d7d7cf077a24ea6ee39de /shared/utils | |
parent | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (diff) | |
download | PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.gz PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.tar.zst PeerTube-07b1a18aa678d260009a93e36606c5c5f585723d.zip |
Add playlist check param tests
Diffstat (limited to 'shared/utils')
-rw-r--r-- | shared/utils/index.ts | 3 | ||||
-rw-r--r-- | shared/utils/videos/video-playlists.ts | 30 |
2 files changed, 18 insertions, 15 deletions
diff --git a/shared/utils/index.ts b/shared/utils/index.ts index 156901372..c09565d95 100644 --- a/shared/utils/index.ts +++ b/shared/utils/index.ts | |||
@@ -13,12 +13,13 @@ export * from './requests/requests' | |||
13 | export * from './requests/check-api-params' | 13 | export * from './requests/check-api-params' |
14 | export * from './server/servers' | 14 | export * from './server/servers' |
15 | export * from './videos/services' | 15 | export * from './videos/services' |
16 | export * from './videos/video-playlists' | ||
16 | export * from './users/users' | 17 | export * from './users/users' |
17 | export * from './videos/video-abuses' | 18 | export * from './videos/video-abuses' |
18 | export * from './videos/video-blacklist' | 19 | export * from './videos/video-blacklist' |
19 | export * from './videos/video-channels' | 20 | export * from './videos/video-channels' |
20 | export * from './videos/video-comments' | 21 | export * from './videos/video-comments' |
21 | export * from './videos/video-playlists' | 22 | export * from './videos/video-streaming-playlists' |
22 | export * from './videos/videos' | 23 | export * from './videos/videos' |
23 | export * from './videos/video-change-ownership' | 24 | export * from './videos/video-change-ownership' |
24 | export * from './feeds/feeds' | 25 | export * from './feeds/feeds' |
diff --git a/shared/utils/videos/video-playlists.ts b/shared/utils/videos/video-playlists.ts index 5186d9c4f..21285688a 100644 --- a/shared/utils/videos/video-playlists.ts +++ b/shared/utils/videos/video-playlists.ts | |||
@@ -31,7 +31,7 @@ function getVideoPlaylist (url: string, playlistId: number | string, statusCodeE | |||
31 | }) | 31 | }) |
32 | } | 32 | } |
33 | 33 | ||
34 | function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = 200) { | 34 | function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = 204) { |
35 | const path = '/api/v1/video-playlists/' + playlistId | 35 | const path = '/api/v1/video-playlists/' + playlistId |
36 | 36 | ||
37 | return makeDeleteRequest({ | 37 | return makeDeleteRequest({ |
@@ -46,7 +46,7 @@ function createVideoPlaylist (options: { | |||
46 | url: string, | 46 | url: string, |
47 | token: string, | 47 | token: string, |
48 | playlistAttrs: VideoPlaylistCreate, | 48 | playlistAttrs: VideoPlaylistCreate, |
49 | expectedStatus: number | 49 | expectedStatus?: number |
50 | }) { | 50 | }) { |
51 | const path = '/api/v1/video-playlists/' | 51 | const path = '/api/v1/video-playlists/' |
52 | 52 | ||
@@ -63,7 +63,7 @@ function createVideoPlaylist (options: { | |||
63 | token: options.token, | 63 | token: options.token, |
64 | fields, | 64 | fields, |
65 | attaches, | 65 | attaches, |
66 | statusCodeExpected: options.expectedStatus | 66 | statusCodeExpected: options.expectedStatus || 200 |
67 | }) | 67 | }) |
68 | } | 68 | } |
69 | 69 | ||
@@ -71,9 +71,10 @@ function updateVideoPlaylist (options: { | |||
71 | url: string, | 71 | url: string, |
72 | token: string, | 72 | token: string, |
73 | playlistAttrs: VideoPlaylistUpdate, | 73 | playlistAttrs: VideoPlaylistUpdate, |
74 | expectedStatus: number | 74 | playlistId: number | string, |
75 | expectedStatus?: number | ||
75 | }) { | 76 | }) { |
76 | const path = '/api/v1/video-playlists/' | 77 | const path = '/api/v1/video-playlists/' + options.playlistId |
77 | 78 | ||
78 | const fields = omit(options.playlistAttrs, 'thumbnailfile') | 79 | const fields = omit(options.playlistAttrs, 'thumbnailfile') |
79 | 80 | ||
@@ -88,7 +89,7 @@ function updateVideoPlaylist (options: { | |||
88 | token: options.token, | 89 | token: options.token, |
89 | fields, | 90 | fields, |
90 | attaches, | 91 | attaches, |
91 | statusCodeExpected: options.expectedStatus | 92 | statusCodeExpected: options.expectedStatus || 204 |
92 | }) | 93 | }) |
93 | } | 94 | } |
94 | 95 | ||
@@ -97,7 +98,7 @@ function addVideoInPlaylist (options: { | |||
97 | token: string, | 98 | token: string, |
98 | playlistId: number | string, | 99 | playlistId: number | string, |
99 | elementAttrs: VideoPlaylistElementCreate | 100 | elementAttrs: VideoPlaylistElementCreate |
100 | expectedStatus: number | 101 | expectedStatus?: number |
101 | }) { | 102 | }) { |
102 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' | 103 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' |
103 | 104 | ||
@@ -106,7 +107,7 @@ function addVideoInPlaylist (options: { | |||
106 | path, | 107 | path, |
107 | token: options.token, | 108 | token: options.token, |
108 | fields: options.elementAttrs, | 109 | fields: options.elementAttrs, |
109 | statusCodeExpected: options.expectedStatus | 110 | statusCodeExpected: options.expectedStatus || 200 |
110 | }) | 111 | }) |
111 | } | 112 | } |
112 | 113 | ||
@@ -116,7 +117,7 @@ function updateVideoPlaylistElement (options: { | |||
116 | playlistId: number | string, | 117 | playlistId: number | string, |
117 | videoId: number | string, | 118 | videoId: number | string, |
118 | elementAttrs: VideoPlaylistElementUpdate, | 119 | elementAttrs: VideoPlaylistElementUpdate, |
119 | expectedStatus: number | 120 | expectedStatus?: number |
120 | }) { | 121 | }) { |
121 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.videoId | 122 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.videoId |
122 | 123 | ||
@@ -125,7 +126,7 @@ function updateVideoPlaylistElement (options: { | |||
125 | path, | 126 | path, |
126 | token: options.token, | 127 | token: options.token, |
127 | fields: options.elementAttrs, | 128 | fields: options.elementAttrs, |
128 | statusCodeExpected: options.expectedStatus | 129 | statusCodeExpected: options.expectedStatus || 204 |
129 | }) | 130 | }) |
130 | } | 131 | } |
131 | 132 | ||
@@ -142,7 +143,7 @@ function removeVideoFromPlaylist (options: { | |||
142 | url: options.url, | 143 | url: options.url, |
143 | path, | 144 | path, |
144 | token: options.token, | 145 | token: options.token, |
145 | statusCodeExpected: options.expectedStatus | 146 | statusCodeExpected: options.expectedStatus || 204 |
146 | }) | 147 | }) |
147 | } | 148 | } |
148 | 149 | ||
@@ -152,14 +153,14 @@ function reorderVideosPlaylist (options: { | |||
152 | playlistId: number | string, | 153 | playlistId: number | string, |
153 | elementAttrs: { | 154 | elementAttrs: { |
154 | startPosition: number, | 155 | startPosition: number, |
155 | insertAfter: number, | 156 | insertAfterPosition: number, |
156 | reorderLength?: number | 157 | reorderLength?: number |
157 | }, | 158 | }, |
158 | expectedStatus: number | 159 | expectedStatus: number |
159 | }) { | 160 | }) { |
160 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' | 161 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/reorder' |
161 | 162 | ||
162 | return makePutBodyRequest({ | 163 | return makePostBodyRequest({ |
163 | url: options.url, | 164 | url: options.url, |
164 | path, | 165 | path, |
165 | token: options.token, | 166 | token: options.token, |
@@ -179,6 +180,7 @@ export { | |||
179 | deleteVideoPlaylist, | 180 | deleteVideoPlaylist, |
180 | 181 | ||
181 | addVideoInPlaylist, | 182 | addVideoInPlaylist, |
183 | updateVideoPlaylistElement, | ||
182 | removeVideoFromPlaylist, | 184 | removeVideoFromPlaylist, |
183 | 185 | ||
184 | reorderVideosPlaylist | 186 | reorderVideosPlaylist |