diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-03-27 20:53:11 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-03-27 20:53:11 +0200 |
commit | 6f0c39e2de400685b7baf8340b9e132f2659365a (patch) | |
tree | b036c6ebf65ff4cb7f5649fc48a0b7201370bddd /server/tests | |
parent | 28974889281523eec5b00dd5596c67d99c5167e5 (diff) | |
download | PeerTube-6f0c39e2de400685b7baf8340b9e132f2659365a.tar.gz PeerTube-6f0c39e2de400685b7baf8340b9e132f2659365a.tar.zst PeerTube-6f0c39e2de400685b7baf8340b9e132f2659365a.zip |
Server: add licence video attribute
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/videos.js | 59 | ||||
-rw-r--r-- | server/tests/api/multiple-pods.js | 16 | ||||
-rw-r--r-- | server/tests/api/single-pod.js | 30 | ||||
-rw-r--r-- | server/tests/real-world/real-world.js | 1 | ||||
-rw-r--r-- | server/tests/real-world/tools/upload.js | 8 | ||||
-rw-r--r-- | server/tests/utils/videos.js | 15 |
6 files changed, 127 insertions, 2 deletions
diff --git a/server/tests/api/check-params/videos.js b/server/tests/api/check-params/videos.js index 03b4db3fe..e58f9893b 100644 --- a/server/tests/api/check-params/videos.js +++ b/server/tests/api/check-params/videos.js | |||
@@ -113,6 +113,7 @@ describe('Test videos API validator', function () { | |||
113 | it('Should fail without name', function (done) { | 113 | it('Should fail without name', function (done) { |
114 | const data = { | 114 | const data = { |
115 | category: 5, | 115 | category: 5, |
116 | licence: 1, | ||
116 | description: 'my super description', | 117 | description: 'my super description', |
117 | tags: [ 'tag1', 'tag2' ] | 118 | tags: [ 'tag1', 'tag2' ] |
118 | } | 119 | } |
@@ -126,6 +127,7 @@ describe('Test videos API validator', function () { | |||
126 | const data = { | 127 | const data = { |
127 | name: 'My very very very very very very very very very very very very very very very very long name', | 128 | name: 'My very very very very very very very very very very very very very very very very long name', |
128 | category: 5, | 129 | category: 5, |
130 | licence: 1, | ||
129 | description: 'my super description', | 131 | description: 'my super description', |
130 | tags: [ 'tag1', 'tag2' ] | 132 | tags: [ 'tag1', 'tag2' ] |
131 | } | 133 | } |
@@ -138,6 +140,7 @@ describe('Test videos API validator', function () { | |||
138 | it('Should fail without a category', function (done) { | 140 | it('Should fail without a category', function (done) { |
139 | const data = { | 141 | const data = { |
140 | name: 'my super name', | 142 | name: 'my super name', |
143 | licence: 1, | ||
141 | description: 'my super description', | 144 | description: 'my super description', |
142 | tags: [ 'tag1', 'tag2' ] | 145 | tags: [ 'tag1', 'tag2' ] |
143 | } | 146 | } |
@@ -151,6 +154,34 @@ describe('Test videos API validator', function () { | |||
151 | const data = { | 154 | const data = { |
152 | name: 'my super name', | 155 | name: 'my super name', |
153 | category: 125, | 156 | category: 125, |
157 | licence: 1, | ||
158 | description: 'my super description', | ||
159 | tags: [ 'tag1', 'tag2' ] | ||
160 | } | ||
161 | const attach = { | ||
162 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
163 | } | ||
164 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | ||
165 | }) | ||
166 | |||
167 | it('Should fail without a licence', function (done) { | ||
168 | const data = { | ||
169 | name: 'my super name', | ||
170 | category: 5, | ||
171 | description: 'my super description', | ||
172 | tags: [ 'tag1', 'tag2' ] | ||
173 | } | ||
174 | const attach = { | ||
175 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
176 | } | ||
177 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | ||
178 | }) | ||
179 | |||
180 | it('Should fail with a bad licence', function (done) { | ||
181 | const data = { | ||
182 | name: 'my super name', | ||
183 | category: 5, | ||
184 | licence: 125, | ||
154 | description: 'my super description', | 185 | description: 'my super description', |
155 | tags: [ 'tag1', 'tag2' ] | 186 | tags: [ 'tag1', 'tag2' ] |
156 | } | 187 | } |
@@ -164,6 +195,7 @@ describe('Test videos API validator', function () { | |||
164 | const data = { | 195 | const data = { |
165 | name: 'my super name', | 196 | name: 'my super name', |
166 | category: 5, | 197 | category: 5, |
198 | licence: 1, | ||
167 | tags: [ 'tag1', 'tag2' ] | 199 | tags: [ 'tag1', 'tag2' ] |
168 | } | 200 | } |
169 | const attach = { | 201 | const attach = { |
@@ -176,6 +208,7 @@ describe('Test videos API validator', function () { | |||
176 | const data = { | 208 | const data = { |
177 | name: 'my super name', | 209 | name: 'my super name', |
178 | category: 5, | 210 | category: 5, |
211 | licence: 1, | ||
179 | description: 'my super description which is very very very very very very very very very very very very very very' + | 212 | description: 'my super description which is very very very very very very very very very very very very very very' + |
180 | 'very very very very very very very very very very very very very very very very very very very very very' + | 213 | 'very very very very very very very very very very very very very very very very very very very very very' + |
181 | 'very very very very very very very very very very very very very very very long', | 214 | 'very very very very very very very very very very very very very very very long', |
@@ -191,6 +224,7 @@ describe('Test videos API validator', function () { | |||
191 | const data = { | 224 | const data = { |
192 | name: 'my super name', | 225 | name: 'my super name', |
193 | category: 5, | 226 | category: 5, |
227 | licence: 1, | ||
194 | description: 'my super description', | 228 | description: 'my super description', |
195 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | 229 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] |
196 | } | 230 | } |
@@ -204,6 +238,7 @@ describe('Test videos API validator', function () { | |||
204 | const data = { | 238 | const data = { |
205 | name: 'my super name', | 239 | name: 'my super name', |
206 | category: 5, | 240 | category: 5, |
241 | licence: 1, | ||
207 | description: 'my super description', | 242 | description: 'my super description', |
208 | tags: [ 'tag1', 't' ] | 243 | tags: [ 'tag1', 't' ] |
209 | } | 244 | } |
@@ -217,6 +252,7 @@ describe('Test videos API validator', function () { | |||
217 | const data = { | 252 | const data = { |
218 | name: 'my super name', | 253 | name: 'my super name', |
219 | category: 5, | 254 | category: 5, |
255 | licence: 1, | ||
220 | description: 'my super description', | 256 | description: 'my super description', |
221 | tags: [ 'mysupertagtoolong', 'tag1' ] | 257 | tags: [ 'mysupertagtoolong', 'tag1' ] |
222 | } | 258 | } |
@@ -230,6 +266,7 @@ describe('Test videos API validator', function () { | |||
230 | const data = { | 266 | const data = { |
231 | name: 'my super name', | 267 | name: 'my super name', |
232 | category: 5, | 268 | category: 5, |
269 | licence: 1, | ||
233 | description: 'my super description', | 270 | description: 'my super description', |
234 | tags: [ 'tag1', 'tag2' ] | 271 | tags: [ 'tag1', 'tag2' ] |
235 | } | 272 | } |
@@ -241,6 +278,7 @@ describe('Test videos API validator', function () { | |||
241 | const data = { | 278 | const data = { |
242 | name: 'my super name', | 279 | name: 'my super name', |
243 | category: 5, | 280 | category: 5, |
281 | licence: 1, | ||
244 | description: 'my super description', | 282 | description: 'my super description', |
245 | tags: [ 'tag1', 'tag2' ] | 283 | tags: [ 'tag1', 'tag2' ] |
246 | } | 284 | } |
@@ -254,6 +292,7 @@ describe('Test videos API validator', function () { | |||
254 | const data = { | 292 | const data = { |
255 | name: 'my super name', | 293 | name: 'my super name', |
256 | category: 5, | 294 | category: 5, |
295 | licence: 1, | ||
257 | description: 'my super description', | 296 | description: 'my super description', |
258 | tags: [ 'tag1', 'tag2' ] | 297 | tags: [ 'tag1', 'tag2' ] |
259 | } | 298 | } |
@@ -267,6 +306,7 @@ describe('Test videos API validator', function () { | |||
267 | const data = { | 306 | const data = { |
268 | name: 'my super name', | 307 | name: 'my super name', |
269 | category: 5, | 308 | category: 5, |
309 | licence: 1, | ||
270 | description: 'my super description', | 310 | description: 'my super description', |
271 | tags: [ 'tag1', 'tag2' ] | 311 | tags: [ 'tag1', 'tag2' ] |
272 | } | 312 | } |
@@ -304,6 +344,7 @@ describe('Test videos API validator', function () { | |||
304 | it('Should fail without a valid uuid', function (done) { | 344 | it('Should fail without a valid uuid', function (done) { |
305 | const data = { | 345 | const data = { |
306 | category: 5, | 346 | category: 5, |
347 | licence: 2, | ||
307 | description: 'my super description', | 348 | description: 'my super description', |
308 | tags: [ 'tag1', 'tag2' ] | 349 | tags: [ 'tag1', 'tag2' ] |
309 | } | 350 | } |
@@ -313,6 +354,7 @@ describe('Test videos API validator', function () { | |||
313 | it('Should fail with an unknown id', function (done) { | 354 | it('Should fail with an unknown id', function (done) { |
314 | const data = { | 355 | const data = { |
315 | category: 5, | 356 | category: 5, |
357 | licence: 2, | ||
316 | description: 'my super description', | 358 | description: 'my super description', |
317 | tags: [ 'tag1', 'tag2' ] | 359 | tags: [ 'tag1', 'tag2' ] |
318 | } | 360 | } |
@@ -323,6 +365,7 @@ describe('Test videos API validator', function () { | |||
323 | const data = { | 365 | const data = { |
324 | name: 'My very very very very very very very very very very very very very very very very long name', | 366 | name: 'My very very very very very very very very very very very very very very very very long name', |
325 | category: 5, | 367 | category: 5, |
368 | licence: 2, | ||
326 | description: 'my super description', | 369 | description: 'my super description', |
327 | tags: [ 'tag1', 'tag2' ] | 370 | tags: [ 'tag1', 'tag2' ] |
328 | } | 371 | } |
@@ -333,6 +376,18 @@ describe('Test videos API validator', function () { | |||
333 | const data = { | 376 | const data = { |
334 | name: 'my super name', | 377 | name: 'my super name', |
335 | category: 128, | 378 | category: 128, |
379 | licence: 2, | ||
380 | description: 'my super description', | ||
381 | tags: [ 'tag1', 'tag2' ] | ||
382 | } | ||
383 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | ||
384 | }) | ||
385 | |||
386 | it('Should fail with a bad licence', function (done) { | ||
387 | const data = { | ||
388 | name: 'my super name', | ||
389 | category: 5, | ||
390 | licence: 128, | ||
336 | description: 'my super description', | 391 | description: 'my super description', |
337 | tags: [ 'tag1', 'tag2' ] | 392 | tags: [ 'tag1', 'tag2' ] |
338 | } | 393 | } |
@@ -343,6 +398,7 @@ describe('Test videos API validator', function () { | |||
343 | const data = { | 398 | const data = { |
344 | name: 'my super name', | 399 | name: 'my super name', |
345 | category: 5, | 400 | category: 5, |
401 | licence: 2, | ||
346 | description: 'my super description which is very very very very very very very very very very very very very very' + | 402 | description: 'my super description which is very very very very very very very very very very very very very very' + |
347 | 'very very very very very very very very very very very very very very very very very very very very very' + | 403 | 'very very very very very very very very very very very very very very very very very very very very very' + |
348 | 'very very very very very very very very very very very very very very very long', | 404 | 'very very very very very very very very very very very very very very very long', |
@@ -355,6 +411,7 @@ describe('Test videos API validator', function () { | |||
355 | const data = { | 411 | const data = { |
356 | name: 'my super name', | 412 | name: 'my super name', |
357 | category: 5, | 413 | category: 5, |
414 | licence: 2, | ||
358 | description: 'my super description', | 415 | description: 'my super description', |
359 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | 416 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] |
360 | } | 417 | } |
@@ -365,6 +422,7 @@ describe('Test videos API validator', function () { | |||
365 | const data = { | 422 | const data = { |
366 | name: 'my super name', | 423 | name: 'my super name', |
367 | category: 5, | 424 | category: 5, |
425 | licence: 2, | ||
368 | description: 'my super description', | 426 | description: 'my super description', |
369 | tags: [ 'tag1', 't' ] | 427 | tags: [ 'tag1', 't' ] |
370 | } | 428 | } |
@@ -375,6 +433,7 @@ describe('Test videos API validator', function () { | |||
375 | const data = { | 433 | const data = { |
376 | name: 'my super name', | 434 | name: 'my super name', |
377 | category: 5, | 435 | category: 5, |
436 | licence: 2, | ||
378 | description: 'my super description', | 437 | description: 'my super description', |
379 | tags: [ 'mysupertagtoolong', 'tag1' ] | 438 | tags: [ 'mysupertagtoolong', 'tag1' ] |
380 | } | 439 | } |
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index d5c723b3b..69ef38c20 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js | |||
@@ -82,6 +82,8 @@ describe('Test multiple pods', function () { | |||
82 | function (next) { | 82 | function (next) { |
83 | const videoAttributes = { | 83 | const videoAttributes = { |
84 | name: 'my super name for pod 1', | 84 | name: 'my super name for pod 1', |
85 | category: 5, | ||
86 | licence: 4, | ||
85 | description: 'my super description for pod 1', | 87 | description: 'my super description for pod 1', |
86 | tags: [ 'tag1p1', 'tag2p1' ], | 88 | tags: [ 'tag1p1', 'tag2p1' ], |
87 | fixture: 'video_short1.webm' | 89 | fixture: 'video_short1.webm' |
@@ -108,6 +110,8 @@ describe('Test multiple pods', function () { | |||
108 | expect(video.name).to.equal('my super name for pod 1') | 110 | expect(video.name).to.equal('my super name for pod 1') |
109 | expect(video.category).to.equal(5) | 111 | expect(video.category).to.equal(5) |
110 | expect(video.categoryLabel).to.equal('Sports') | 112 | expect(video.categoryLabel).to.equal('Sports') |
113 | expect(video.licence).to.equal(4) | ||
114 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial') | ||
111 | expect(video.description).to.equal('my super description for pod 1') | 115 | expect(video.description).to.equal('my super description for pod 1') |
112 | expect(video.podHost).to.equal('localhost:9001') | 116 | expect(video.podHost).to.equal('localhost:9001') |
113 | expect(video.magnetUri).to.exist | 117 | expect(video.magnetUri).to.exist |
@@ -150,6 +154,7 @@ describe('Test multiple pods', function () { | |||
150 | const videoAttributes = { | 154 | const videoAttributes = { |
151 | name: 'my super name for pod 2', | 155 | name: 'my super name for pod 2', |
152 | category: 4, | 156 | category: 4, |
157 | licence: 3, | ||
153 | description: 'my super description for pod 2', | 158 | description: 'my super description for pod 2', |
154 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], | 159 | tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ], |
155 | fixture: 'video_short2.webm' | 160 | fixture: 'video_short2.webm' |
@@ -176,6 +181,8 @@ describe('Test multiple pods', function () { | |||
176 | expect(video.name).to.equal('my super name for pod 2') | 181 | expect(video.name).to.equal('my super name for pod 2') |
177 | expect(video.category).to.equal(4) | 182 | expect(video.category).to.equal(4) |
178 | expect(video.categoryLabel).to.equal('Art') | 183 | expect(video.categoryLabel).to.equal('Art') |
184 | expect(video.licence).to.equal(3) | ||
185 | expect(video.licenceLabel).to.equal('Attribution - No Derivatives') | ||
179 | expect(video.description).to.equal('my super description for pod 2') | 186 | expect(video.description).to.equal('my super description for pod 2') |
180 | expect(video.podHost).to.equal('localhost:9002') | 187 | expect(video.podHost).to.equal('localhost:9002') |
181 | expect(video.magnetUri).to.exist | 188 | expect(video.magnetUri).to.exist |
@@ -218,6 +225,7 @@ describe('Test multiple pods', function () { | |||
218 | const videoAttributes = { | 225 | const videoAttributes = { |
219 | name: 'my super name for pod 3', | 226 | name: 'my super name for pod 3', |
220 | category: 6, | 227 | category: 6, |
228 | licence: 5, | ||
221 | description: 'my super description for pod 3', | 229 | description: 'my super description for pod 3', |
222 | tags: [ 'tag1p3' ], | 230 | tags: [ 'tag1p3' ], |
223 | fixture: 'video_short3.webm' | 231 | fixture: 'video_short3.webm' |
@@ -228,6 +236,7 @@ describe('Test multiple pods', function () { | |||
228 | const videoAttributes = { | 236 | const videoAttributes = { |
229 | name: 'my super name for pod 3-2', | 237 | name: 'my super name for pod 3-2', |
230 | category: 7, | 238 | category: 7, |
239 | licence: 6, | ||
231 | description: 'my super description for pod 3-2', | 240 | description: 'my super description for pod 3-2', |
232 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], | 241 | tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], |
233 | fixture: 'video_short.webm' | 242 | fixture: 'video_short.webm' |
@@ -264,6 +273,8 @@ describe('Test multiple pods', function () { | |||
264 | expect(video1.name).to.equal('my super name for pod 3') | 273 | expect(video1.name).to.equal('my super name for pod 3') |
265 | expect(video1.category).to.equal(6) | 274 | expect(video1.category).to.equal(6) |
266 | expect(video1.categoryLabel).to.equal('Travels') | 275 | expect(video1.categoryLabel).to.equal('Travels') |
276 | expect(video1.licence).to.equal(5) | ||
277 | expect(video1.licenceLabel).to.equal('Attribution - Non Commercial - Share Alike') | ||
267 | expect(video1.description).to.equal('my super description for pod 3') | 278 | expect(video1.description).to.equal('my super description for pod 3') |
268 | expect(video1.podHost).to.equal('localhost:9003') | 279 | expect(video1.podHost).to.equal('localhost:9003') |
269 | expect(video1.magnetUri).to.exist | 280 | expect(video1.magnetUri).to.exist |
@@ -276,6 +287,8 @@ describe('Test multiple pods', function () { | |||
276 | expect(video2.name).to.equal('my super name for pod 3-2') | 287 | expect(video2.name).to.equal('my super name for pod 3-2') |
277 | expect(video2.category).to.equal(7) | 288 | expect(video2.category).to.equal(7) |
278 | expect(video2.categoryLabel).to.equal('Gaming') | 289 | expect(video2.categoryLabel).to.equal('Gaming') |
290 | expect(video2.licence).to.equal(6) | ||
291 | expect(video2.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
279 | expect(video2.description).to.equal('my super description for pod 3-2') | 292 | expect(video2.description).to.equal('my super description for pod 3-2') |
280 | expect(video2.podHost).to.equal('localhost:9003') | 293 | expect(video2.podHost).to.equal('localhost:9003') |
281 | expect(video2.magnetUri).to.exist | 294 | expect(video2.magnetUri).to.exist |
@@ -624,6 +637,7 @@ describe('Test multiple pods', function () { | |||
624 | const attributes = { | 637 | const attributes = { |
625 | name: 'my super video updated', | 638 | name: 'my super video updated', |
626 | category: 10, | 639 | category: 10, |
640 | licence: 7, | ||
627 | description: 'my super description updated', | 641 | description: 'my super description updated', |
628 | tags: [ 'tagup1', 'tagup2' ] | 642 | tags: [ 'tagup1', 'tagup2' ] |
629 | } | 643 | } |
@@ -652,6 +666,8 @@ describe('Test multiple pods', function () { | |||
652 | expect(!!videoUpdated).to.be.true | 666 | expect(!!videoUpdated).to.be.true |
653 | expect(videoUpdated.category).to.equal(10) | 667 | expect(videoUpdated.category).to.equal(10) |
654 | expect(videoUpdated.categoryLabel).to.equal('Entertainment') | 668 | expect(videoUpdated.categoryLabel).to.equal('Entertainment') |
669 | expect(videoUpdated.licence).to.equal(7) | ||
670 | expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication') | ||
655 | expect(videoUpdated.description).to.equal('my super description updated') | 671 | expect(videoUpdated.description).to.equal('my super description updated') |
656 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | 672 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) |
657 | expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true | 673 | expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true |
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js index 9465f6034..6d7ebdc9b 100644 --- a/server/tests/api/single-pod.js +++ b/server/tests/api/single-pod.js | |||
@@ -57,6 +57,19 @@ describe('Test a single pod', function () { | |||
57 | }) | 57 | }) |
58 | }) | 58 | }) |
59 | 59 | ||
60 | it('Should list video licences', function (done) { | ||
61 | videosUtils.getVideoLicences(server.url, function (err, res) { | ||
62 | if (err) throw err | ||
63 | |||
64 | const licences = res.body | ||
65 | expect(Object.keys(licences)).to.have.length.above(5) | ||
66 | |||
67 | expect(licences[3]).to.equal('Attribution - No Derivatives') | ||
68 | |||
69 | done() | ||
70 | }) | ||
71 | }) | ||
72 | |||
60 | it('Should not have videos', function (done) { | 73 | it('Should not have videos', function (done) { |
61 | videosUtils.getVideosList(server.url, function (err, res) { | 74 | videosUtils.getVideosList(server.url, function (err, res) { |
62 | if (err) throw err | 75 | if (err) throw err |
@@ -73,6 +86,7 @@ describe('Test a single pod', function () { | |||
73 | const videoAttributes = { | 86 | const videoAttributes = { |
74 | name: 'my super name', | 87 | name: 'my super name', |
75 | category: 2, | 88 | category: 2, |
89 | licence: 6, | ||
76 | tags: [ 'tag1', 'tag2', 'tag3' ] | 90 | tags: [ 'tag1', 'tag2', 'tag3' ] |
77 | } | 91 | } |
78 | videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, done) | 92 | videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, done) |
@@ -93,6 +107,8 @@ describe('Test a single pod', function () { | |||
93 | expect(video.name).to.equal('my super name') | 107 | expect(video.name).to.equal('my super name') |
94 | expect(video.category).to.equal(2) | 108 | expect(video.category).to.equal(2) |
95 | expect(video.categoryLabel).to.equal('Films') | 109 | expect(video.categoryLabel).to.equal('Films') |
110 | expect(video.licence).to.equal(6) | ||
111 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
96 | expect(video.description).to.equal('my super description') | 112 | expect(video.description).to.equal('my super description') |
97 | expect(video.podHost).to.equal('localhost:9001') | 113 | expect(video.podHost).to.equal('localhost:9001') |
98 | expect(video.magnetUri).to.exist | 114 | expect(video.magnetUri).to.exist |
@@ -130,6 +146,8 @@ describe('Test a single pod', function () { | |||
130 | expect(video.name).to.equal('my super name') | 146 | expect(video.name).to.equal('my super name') |
131 | expect(video.category).to.equal(2) | 147 | expect(video.category).to.equal(2) |
132 | expect(video.categoryLabel).to.equal('Films') | 148 | expect(video.categoryLabel).to.equal('Films') |
149 | expect(video.licence).to.equal(6) | ||
150 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
133 | expect(video.description).to.equal('my super description') | 151 | expect(video.description).to.equal('my super description') |
134 | expect(video.podHost).to.equal('localhost:9001') | 152 | expect(video.podHost).to.equal('localhost:9001') |
135 | expect(video.magnetUri).to.exist | 153 | expect(video.magnetUri).to.exist |
@@ -171,6 +189,8 @@ describe('Test a single pod', function () { | |||
171 | expect(video.name).to.equal('my super name') | 189 | expect(video.name).to.equal('my super name') |
172 | expect(video.category).to.equal(2) | 190 | expect(video.category).to.equal(2) |
173 | expect(video.categoryLabel).to.equal('Films') | 191 | expect(video.categoryLabel).to.equal('Films') |
192 | expect(video.licence).to.equal(6) | ||
193 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
174 | expect(video.description).to.equal('my super description') | 194 | expect(video.description).to.equal('my super description') |
175 | expect(video.podHost).to.equal('localhost:9001') | 195 | expect(video.podHost).to.equal('localhost:9001') |
176 | expect(video.author).to.equal('root') | 196 | expect(video.author).to.equal('root') |
@@ -228,6 +248,8 @@ describe('Test a single pod', function () { | |||
228 | expect(video.name).to.equal('my super name') | 248 | expect(video.name).to.equal('my super name') |
229 | expect(video.category).to.equal(2) | 249 | expect(video.category).to.equal(2) |
230 | expect(video.categoryLabel).to.equal('Films') | 250 | expect(video.categoryLabel).to.equal('Films') |
251 | expect(video.licence).to.equal(6) | ||
252 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | ||
231 | expect(video.description).to.equal('my super description') | 253 | expect(video.description).to.equal('my super description') |
232 | expect(video.podHost).to.equal('localhost:9001') | 254 | expect(video.podHost).to.equal('localhost:9001') |
233 | expect(video.author).to.equal('root') | 255 | expect(video.author).to.equal('root') |
@@ -324,6 +346,7 @@ describe('Test a single pod', function () { | |||
324 | name: video + ' name', | 346 | name: video + ' name', |
325 | description: video + ' description', | 347 | description: video + ' description', |
326 | category: 2, | 348 | category: 2, |
349 | licence: 1, | ||
327 | tags: [ 'tag1', 'tag2', 'tag3' ], | 350 | tags: [ 'tag1', 'tag2', 'tag3' ], |
328 | fixture: video | 351 | fixture: video |
329 | } | 352 | } |
@@ -548,6 +571,7 @@ describe('Test a single pod', function () { | |||
548 | const attributes = { | 571 | const attributes = { |
549 | name: 'my super video updated', | 572 | name: 'my super video updated', |
550 | category: 4, | 573 | category: 4, |
574 | licence: 2, | ||
551 | description: 'my super description updated', | 575 | description: 'my super description updated', |
552 | tags: [ 'tagup1', 'tagup2' ] | 576 | tags: [ 'tagup1', 'tagup2' ] |
553 | } | 577 | } |
@@ -565,6 +589,8 @@ describe('Test a single pod', function () { | |||
565 | expect(video.name).to.equal('my super video updated') | 589 | expect(video.name).to.equal('my super video updated') |
566 | expect(video.category).to.equal(4) | 590 | expect(video.category).to.equal(4) |
567 | expect(video.categoryLabel).to.equal('Art') | 591 | expect(video.categoryLabel).to.equal('Art') |
592 | expect(video.licence).to.equal(2) | ||
593 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | ||
568 | expect(video.description).to.equal('my super description updated') | 594 | expect(video.description).to.equal('my super description updated') |
569 | expect(video.podHost).to.equal('localhost:9001') | 595 | expect(video.podHost).to.equal('localhost:9001') |
570 | expect(video.author).to.equal('root') | 596 | expect(video.author).to.equal('root') |
@@ -604,6 +630,8 @@ describe('Test a single pod', function () { | |||
604 | expect(video.name).to.equal('my super video updated') | 630 | expect(video.name).to.equal('my super video updated') |
605 | expect(video.category).to.equal(4) | 631 | expect(video.category).to.equal(4) |
606 | expect(video.categoryLabel).to.equal('Art') | 632 | expect(video.categoryLabel).to.equal('Art') |
633 | expect(video.licence).to.equal(2) | ||
634 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | ||
607 | expect(video.description).to.equal('my super description updated') | 635 | expect(video.description).to.equal('my super description updated') |
608 | expect(video.podHost).to.equal('localhost:9001') | 636 | expect(video.podHost).to.equal('localhost:9001') |
609 | expect(video.author).to.equal('root') | 637 | expect(video.author).to.equal('root') |
@@ -633,6 +661,8 @@ describe('Test a single pod', function () { | |||
633 | expect(video.name).to.equal('my super video updated') | 661 | expect(video.name).to.equal('my super video updated') |
634 | expect(video.category).to.equal(4) | 662 | expect(video.category).to.equal(4) |
635 | expect(video.categoryLabel).to.equal('Art') | 663 | expect(video.categoryLabel).to.equal('Art') |
664 | expect(video.licence).to.equal(2) | ||
665 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | ||
636 | expect(video.description).to.equal('hello everybody') | 666 | expect(video.description).to.equal('hello everybody') |
637 | expect(video.podHost).to.equal('localhost:9001') | 667 | expect(video.podHost).to.equal('localhost:9001') |
638 | expect(video.author).to.equal('root') | 668 | expect(video.author).to.equal('root') |
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js index 32afeec68..7777768c8 100644 --- a/server/tests/real-world/real-world.js +++ b/server/tests/real-world/real-world.js | |||
@@ -205,6 +205,7 @@ function upload (servers, numServer, callback) { | |||
205 | const videoAttributes = { | 205 | const videoAttributes = { |
206 | name: Date.now() + ' name', | 206 | name: Date.now() + ' name', |
207 | category: 4, | 207 | category: 4, |
208 | licence: 2, | ||
208 | description: Date.now() + ' description', | 209 | description: Date.now() + ' description', |
209 | tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ], | 210 | tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ], |
210 | fixture: 'video_short1.webm' | 211 | fixture: 'video_short1.webm' |
diff --git a/server/tests/real-world/tools/upload.js b/server/tests/real-world/tools/upload.js index 856251c7f..7b97ebf0b 100644 --- a/server/tests/real-world/tools/upload.js +++ b/server/tests/real-world/tools/upload.js | |||
@@ -9,7 +9,8 @@ program | |||
9 | .option('-u, --url <url>', 'Server url') | 9 | .option('-u, --url <url>', 'Server url') |
10 | .option('-a, --access-token <token>', 'Access token') | 10 | .option('-a, --access-token <token>', 'Access token') |
11 | .option('-n, --name <name>', 'Video name') | 11 | .option('-n, --name <name>', 'Video name') |
12 | .option('-d, --category <category number>', 'Category number') | 12 | .option('-c, --category <category number>', 'Category number') |
13 | .option('-l, --licence <licence number>', 'Licence number') | ||
13 | .option('-d, --description <description>', 'Video description') | 14 | .option('-d, --description <description>', 'Video description') |
14 | .option('-t, --tags <tags>', 'Video tags', list) | 15 | .option('-t, --tags <tags>', 'Video tags', list) |
15 | .option('-f, --file <file>', 'Video absolute file path') | 16 | .option('-f, --file <file>', 'Video absolute file path') |
@@ -20,6 +21,7 @@ if ( | |||
20 | !program.accessToken || | 21 | !program.accessToken || |
21 | !program.name || | 22 | !program.name || |
22 | !program.category || | 23 | !program.category || |
24 | !program.licence || | ||
23 | !program.description || | 25 | !program.description || |
24 | !program.tags || | 26 | !program.tags || |
25 | !Array.isArray(program.tags) || | 27 | !Array.isArray(program.tags) || |
@@ -37,6 +39,7 @@ fs.access(program.file, fs.F_OK, function (err) { | |||
37 | program.accessToken, | 39 | program.accessToken, |
38 | program.name, | 40 | program.name, |
39 | program.category, | 41 | program.category, |
42 | program.licence, | ||
40 | program.description, | 43 | program.description, |
41 | program.tags, | 44 | program.tags, |
42 | program.file | 45 | program.file |
@@ -49,12 +52,13 @@ function list (val) { | |||
49 | return val.split(',') | 52 | return val.split(',') |
50 | } | 53 | } |
51 | 54 | ||
52 | function upload (url, accessToken, name, category, description, tags, fixture) { | 55 | function upload (url, accessToken, name, category, licence, description, tags, fixture) { |
53 | console.log('Uploading %s video...', program.name) | 56 | console.log('Uploading %s video...', program.name) |
54 | 57 | ||
55 | const videoAttributes = { | 58 | const videoAttributes = { |
56 | name, | 59 | name, |
57 | category, | 60 | category, |
61 | licence, | ||
58 | description, | 62 | description, |
59 | tags, | 63 | tags, |
60 | fixture | 64 | fixture |
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js index ad0d74076..d1e0b7b14 100644 --- a/server/tests/utils/videos.js +++ b/server/tests/utils/videos.js | |||
@@ -6,6 +6,7 @@ const request = require('supertest') | |||
6 | 6 | ||
7 | const videosUtils = { | 7 | const videosUtils = { |
8 | getVideoCategories, | 8 | getVideoCategories, |
9 | getVideoLicences, | ||
9 | getAllVideosListBy, | 10 | getAllVideosListBy, |
10 | getVideo, | 11 | getVideo, |
11 | getVideosList, | 12 | getVideosList, |
@@ -34,6 +35,17 @@ function getVideoCategories (url, end) { | |||
34 | .end(end) | 35 | .end(end) |
35 | } | 36 | } |
36 | 37 | ||
38 | function getVideoLicences (url, end) { | ||
39 | const path = '/api/v1/videos/licences' | ||
40 | |||
41 | request(url) | ||
42 | .get(path) | ||
43 | .set('Accept', 'application/json') | ||
44 | .expect(200) | ||
45 | .expect('Content-Type', /json/) | ||
46 | .end(end) | ||
47 | } | ||
48 | |||
37 | function getAllVideosListBy (url, end) { | 49 | function getAllVideosListBy (url, end) { |
38 | const path = '/api/v1/videos' | 50 | const path = '/api/v1/videos' |
39 | 51 | ||
@@ -205,6 +217,7 @@ function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end) | |||
205 | let attributes = { | 217 | let attributes = { |
206 | name: 'my super video', | 218 | name: 'my super video', |
207 | category: 5, | 219 | category: 5, |
220 | licence: 4, | ||
208 | description: 'my super description', | 221 | description: 'my super description', |
209 | tags: [ 'tag' ], | 222 | tags: [ 'tag' ], |
210 | fixture: 'video_short.webm' | 223 | fixture: 'video_short.webm' |
@@ -217,6 +230,7 @@ function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end) | |||
217 | .set('Authorization', 'Bearer ' + accessToken) | 230 | .set('Authorization', 'Bearer ' + accessToken) |
218 | .field('name', attributes.name) | 231 | .field('name', attributes.name) |
219 | .field('category', attributes.category) | 232 | .field('category', attributes.category) |
233 | .field('licence', attributes.licence) | ||
220 | .field('description', attributes.description) | 234 | .field('description', attributes.description) |
221 | 235 | ||
222 | for (let i = 0; i < attributes.tags.length; i++) { | 236 | for (let i = 0; i < attributes.tags.length; i++) { |
@@ -250,6 +264,7 @@ function updateVideo (url, accessToken, id, attributes, specialStatus, end) { | |||
250 | 264 | ||
251 | if (attributes.name) req.field('name', attributes.name) | 265 | if (attributes.name) req.field('name', attributes.name) |
252 | if (attributes.category) req.field('category', attributes.category) | 266 | if (attributes.category) req.field('category', attributes.category) |
267 | if (attributes.licence) req.field('licence', attributes.licence) | ||
253 | if (attributes.description) req.field('description', attributes.description) | 268 | if (attributes.description) req.field('description', attributes.description) |
254 | 269 | ||
255 | if (attributes.tags) { | 270 | if (attributes.tags) { |