]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/single-pod.js
1 /* eslint-disable no-unused-expressions */
5 const chai
= require('chai')
6 const each
= require('async/each')
7 const expect
= chai
.expect
8 const fs
= require('fs')
9 const keyBy
= require('lodash/keyBy')
10 const pathUtils
= require('path')
11 const series
= require('async/series')
12 const webtorrent
= new (require('webtorrent'))()
14 const loginUtils
= require('../utils/login')
15 const miscsUtils
= require('../utils/miscs')
16 const serversUtils
= require('../utils/servers')
17 const videosUtils
= require('../utils/videos')
19 describe('Test a single pod', function () {
23 let videosListBase
= null
25 before(function (done
) {
30 serversUtils
.flushTests(next
)
33 serversUtils
.runServer(1, function (server1
) {
39 loginUtils
.loginAndGetAccessToken(server
, function (err
, token
) {
41 server
.accessToken
= token
48 it('Should list video categories', function (done
) {
49 videosUtils
.getVideoCategories(server
.url
, function (err
, res
) {
52 const categories
= res
.body
53 expect(Object
.keys(categories
)).to
.have
.length
.above(10)
55 expect(categories
[11]).to
.equal('News')
61 it('Should list video licences', function (done
) {
62 videosUtils
.getVideoLicences(server
.url
, function (err
, res
) {
65 const licences
= res
.body
66 expect(Object
.keys(licences
)).to
.have
.length
.above(5)
68 expect(licences
[3]).to
.equal('Attribution - No Derivatives')
74 it('Should list video languages', function (done
) {
75 videosUtils
.getVideoLanguages(server
.url
, function (err
, res
) {
78 const languages
= res
.body
79 expect(Object
.keys(languages
)).to
.have
.length
.above(5)
81 expect(languages
[3]).to
.equal('Mandarin')
87 it('Should not have videos', function (done
) {
88 videosUtils
.getVideosList(server
.url
, function (err
, res
) {
91 expect(res
.body
.total
).to
.equal(0)
92 expect(res
.body
.data
).to
.be
.an('array')
93 expect(res
.body
.data
.length
).to
.equal(0)
99 it('Should upload the video', function (done
) {
100 const videoAttributes
= {
101 name: 'my super name',
105 tags: [ 'tag1', 'tag2', 'tag3' ]
107 videosUtils
.uploadVideo(server
.url
, server
.accessToken
, videoAttributes
, done
)
110 it('Should seed the uploaded video', function (done
) {
111 // Yes, this could be long
114 videosUtils
.getVideosList(server
.url
, function (err
, res
) {
117 expect(res
.body
.total
).to
.equal(1)
118 expect(res
.body
.data
).to
.be
.an('array')
119 expect(res
.body
.data
.length
).to
.equal(1)
121 const video
= res
.body
.data
[0]
122 expect(video
.name
).to
.equal('my super name')
123 expect(video
.category
).to
.equal(2)
124 expect(video
.categoryLabel
).to
.equal('Films')
125 expect(video
.licence
).to
.equal(6)
126 expect(video
.licenceLabel
).to
.equal('Attribution - Non Commercial - No Derivatives')
127 expect(video
.language
).to
.equal(3)
128 expect(video
.languageLabel
).to
.equal('Mandarin')
129 expect(video
.nsfw
).to
.be
.ok
130 expect(video
.description
).to
.equal('my super description')
131 expect(video
.podHost
).to
.equal('localhost:9001')
132 expect(video
.author
).to
.equal('root')
133 expect(video
.isLocal
).to
.be
.true
134 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'tag3' ])
135 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
136 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
138 expect(video
.files
).to
.have
.lengthOf(1)
140 const file
= video
.files
[0]
141 const magnetUri
= file
.magnetUri
142 expect(file
.magnetUri
).to
.exist
143 expect(file
.resolution
).to
.equal(0)
144 expect(file
.resolutionLabel
).to
.equal('original')
145 expect(file
.size
).to
.equal(218910)
147 videosUtils
.testVideoImage(server
.url
, 'video_short.webm', video
.thumbnailPath
, function (err
, test
) {
149 expect(test
).to
.equal(true)
152 videoUUID
= video
.uuid
154 webtorrent
.add(magnetUri
, function (torrent
) {
155 expect(torrent
.files
).to
.exist
156 expect(torrent
.files
.length
).to
.equal(1)
157 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
165 it('Should get the video', function (done
) {
166 // Yes, this could be long
169 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
172 const video
= res
.body
173 expect(video
.name
).to
.equal('my super name')
174 expect(video
.category
).to
.equal(2)
175 expect(video
.categoryLabel
).to
.equal('Films')
176 expect(video
.licence
).to
.equal(6)
177 expect(video
.licenceLabel
).to
.equal('Attribution - Non Commercial - No Derivatives')
178 expect(video
.language
).to
.equal(3)
179 expect(video
.languageLabel
).to
.equal('Mandarin')
180 expect(video
.nsfw
).to
.be
.ok
181 expect(video
.description
).to
.equal('my super description')
182 expect(video
.podHost
).to
.equal('localhost:9001')
183 expect(video
.author
).to
.equal('root')
184 expect(video
.isLocal
).to
.be
.true
185 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'tag3' ])
186 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
187 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
189 expect(video
.files
).to
.have
.lengthOf(1)
191 const file
= video
.files
[0]
192 const magnetUri
= file
.magnetUri
193 expect(file
.magnetUri
).to
.exist
194 expect(file
.resolution
).to
.equal(0)
195 expect(file
.resolutionLabel
).to
.equal('original')
196 expect(file
.size
).to
.equal(218910)
198 videosUtils
.testVideoImage(server
.url
, 'video_short.webm', video
.thumbnailPath
, function (err
, test
) {
200 expect(test
).to
.equal(true)
202 // Wait the async views increment
203 setTimeout(done
, 500)
208 it('Should get the video by UUID', function (done
) {
209 // Yes, this could be long
212 videosUtils
.getVideo(server
.url
, videoUUID
, function (err
, res
) {
215 const video
= res
.body
216 expect(video
.name
).to
.equal('my super name')
218 // Wait the async views increment
219 setTimeout(done
, 500)
223 it('Should have the views updated', function (done
) {
224 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
227 const video
= res
.body
228 expect(video
.views
).to
.equal(2)
234 it('Should search the video by name by default', function (done
) {
235 videosUtils
.searchVideo(server
.url
, 'my', function (err
, res
) {
238 expect(res
.body
.total
).to
.equal(1)
239 expect(res
.body
.data
).to
.be
.an('array')
240 expect(res
.body
.data
.length
).to
.equal(1)
242 const video
= res
.body
.data
[0]
243 expect(video
.name
).to
.equal('my super name')
244 expect(video
.category
).to
.equal(2)
245 expect(video
.categoryLabel
).to
.equal('Films')
246 expect(video
.licence
).to
.equal(6)
247 expect(video
.licenceLabel
).to
.equal('Attribution - Non Commercial - No Derivatives')
248 expect(video
.language
).to
.equal(3)
249 expect(video
.languageLabel
).to
.equal('Mandarin')
250 expect(video
.nsfw
).to
.be
.ok
251 expect(video
.description
).to
.equal('my super description')
252 expect(video
.podHost
).to
.equal('localhost:9001')
253 expect(video
.author
).to
.equal('root')
254 expect(video
.isLocal
).to
.be
.true
255 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'tag3' ])
256 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
257 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
259 expect(video
.files
).to
.have
.lengthOf(1)
261 const file
= video
.files
[0]
262 const magnetUri
= file
.magnetUri
263 expect(file
.magnetUri
).to
.exist
264 expect(file
.resolution
).to
.equal(0)
265 expect(file
.resolutionLabel
).to
.equal('original')
266 expect(file
.size
).to
.equal(218910)
268 videosUtils
.testVideoImage(server
.url
, 'video_short.webm', video
.thumbnailPath
, function (err
, test
) {
270 expect(test
).to
.equal(true)
277 // Not implemented yet
278 // it('Should search the video by podHost', function (done) {
279 // videosUtils.searchVideo(server.url, '9001', 'host', function (err, res) {
280 // if (err) throw err
282 // expect(res.body.total).to.equal(1)
283 // expect(res.body.data).to.be.an('array')
284 // expect(res.body.data.length).to.equal(1)
286 // const video = res.body.data[0]
287 // expect(video.name).to.equal('my super name')
288 // expect(video.description).to.equal('my super description')
289 // expect(video.podHost).to.equal('localhost:9001')
290 // expect(video.author).to.equal('root')
291 // expect(video.isLocal).to.be.true
292 // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
293 // expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
294 // expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
296 // videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
297 // if (err) throw err
298 // expect(test).to.equal(true)
305 it('Should search the video by tag', function (done
) {
306 videosUtils
.searchVideo(server
.url
, 'tag1', 'tags', function (err
, res
) {
309 expect(res
.body
.total
).to
.equal(1)
310 expect(res
.body
.data
).to
.be
.an('array')
311 expect(res
.body
.data
.length
).to
.equal(1)
313 const video
= res
.body
.data
[0]
314 expect(video
.name
).to
.equal('my super name')
315 expect(video
.category
).to
.equal(2)
316 expect(video
.categoryLabel
).to
.equal('Films')
317 expect(video
.licence
).to
.equal(6)
318 expect(video
.licenceLabel
).to
.equal('Attribution - Non Commercial - No Derivatives')
319 expect(video
.language
).to
.equal(3)
320 expect(video
.languageLabel
).to
.equal('Mandarin')
321 expect(video
.nsfw
).to
.be
.ok
322 expect(video
.description
).to
.equal('my super description')
323 expect(video
.podHost
).to
.equal('localhost:9001')
324 expect(video
.author
).to
.equal('root')
325 expect(video
.isLocal
).to
.be
.true
326 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'tag3' ])
327 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
328 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
330 expect(video
.files
).to
.have
.lengthOf(1)
332 const file
= video
.files
[0]
333 const magnetUri
= file
.magnetUri
334 expect(file
.magnetUri
).to
.exist
335 expect(file
.resolution
).to
.equal(0)
336 expect(file
.resolutionLabel
).to
.equal('original')
337 expect(file
.size
).to
.equal(218910)
339 videosUtils
.testVideoImage(server
.url
, 'video_short.webm', video
.thumbnailPath
, function (err
, test
) {
341 expect(test
).to
.equal(true)
348 it('Should not find a search by name by default', function (done
) {
349 videosUtils
.searchVideo(server
.url
, 'hello', function (err
, res
) {
352 expect(res
.body
.total
).to
.equal(0)
353 expect(res
.body
.data
).to
.be
.an('array')
354 expect(res
.body
.data
.length
).to
.equal(0)
360 it('Should not find a search by author', function (done
) {
361 videosUtils
.searchVideo(server
.url
, 'hello', 'author', function (err
, res
) {
364 expect(res
.body
.total
).to
.equal(0)
365 expect(res
.body
.data
).to
.be
.an('array')
366 expect(res
.body
.data
.length
).to
.equal(0)
372 it('Should not find a search by tag', function (done
) {
373 videosUtils
.searchVideo(server
.url
, 'hello', 'tags', function (err
, res
) {
376 expect(res
.body
.total
).to
.equal(0)
377 expect(res
.body
.data
).to
.be
.an('array')
378 expect(res
.body
.data
.length
).to
.equal(0)
384 it('Should remove the video', function (done
) {
385 videosUtils
.removeVideo(server
.url
, server
.accessToken
, videoId
, function (err
) {
388 fs
.readdir(pathUtils
.join(__dirname
, '..', '..', '..', 'test1/videos/'), function (err
, files
) {
391 expect(files
.length
).to
.equal(0)
393 fs
.readdir(pathUtils
.join(__dirname
, '..', '..', '..', 'test1/thumbnails/'), function (err
, files
) {
396 expect(files
.length
).to
.equal(0)
404 it('Should not have videos', function (done
) {
405 videosUtils
.getVideosList(server
.url
, function (err
, res
) {
408 expect(res
.body
.total
).to
.equal(0)
409 expect(res
.body
.data
).to
.be
.an('array')
410 expect(res
.body
.data
.length
).to
.equal(0)
416 it('Should upload 6 videos', function (done
) {
419 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
420 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
422 each(videos
, function (video
, callbackEach
) {
423 const videoAttributes
= {
424 name: video
+ ' name',
425 description: video
+ ' description',
430 tags: [ 'tag1', 'tag2', 'tag3' ],
434 videosUtils
.uploadVideo(server
.url
, server
.accessToken
, videoAttributes
, callbackEach
)
438 it('Should have the correct durations', function (done
) {
439 videosUtils
.getVideosList(server
.url
, function (err
, res
) {
442 expect(res
.body
.total
).to
.equal(6)
443 const videos
= res
.body
.data
444 expect(videos
).to
.be
.an('array')
445 expect(videos
.length
).to
.equal(6)
447 const videosByName
= keyBy(videos
, 'name')
448 expect(videosByName
['video_short.mp4 name'].duration
).to
.equal(5)
449 expect(videosByName
['video_short.ogv name'].duration
).to
.equal(5)
450 expect(videosByName
['video_short.webm name'].duration
).to
.equal(5)
451 expect(videosByName
['video_short1.webm name'].duration
).to
.equal(10)
452 expect(videosByName
['video_short2.webm name'].duration
).to
.equal(5)
453 expect(videosByName
['video_short3.webm name'].duration
).to
.equal(5)
459 it('Should have the correct thumbnails', function (done
) {
460 videosUtils
.getVideosList(server
.url
, function (err
, res
) {
463 const videos
= res
.body
.data
465 videosListBase
= videos
467 each(videos
, function (video
, callbackEach
) {
469 const videoName
= video
.name
.replace(' name', '')
471 videosUtils
.testVideoImage(server
.url
, videoName
, video
.thumbnailPath
, function (err
, test
) {
474 expect(test
).to
.equal(true)
481 it('Should list only the two first videos', function (done
) {
482 videosUtils
.getVideosListPagination(server
.url
, 0, 2, 'name', function (err
, res
) {
485 const videos
= res
.body
.data
486 expect(res
.body
.total
).to
.equal(6)
487 expect(videos
.length
).to
.equal(2)
488 expect(videos
[0].name
).to
.equal(videosListBase
[0].name
)
489 expect(videos
[1].name
).to
.equal(videosListBase
[1].name
)
495 it('Should list only the next three videos', function (done
) {
496 videosUtils
.getVideosListPagination(server
.url
, 2, 3, 'name', function (err
, res
) {
499 const videos
= res
.body
.data
500 expect(res
.body
.total
).to
.equal(6)
501 expect(videos
.length
).to
.equal(3)
502 expect(videos
[0].name
).to
.equal(videosListBase
[2].name
)
503 expect(videos
[1].name
).to
.equal(videosListBase
[3].name
)
504 expect(videos
[2].name
).to
.equal(videosListBase
[4].name
)
510 it('Should list the last video', function (done
) {
511 videosUtils
.getVideosListPagination(server
.url
, 5, 6, 'name', function (err
, res
) {
514 const videos
= res
.body
.data
515 expect(res
.body
.total
).to
.equal(6)
516 expect(videos
.length
).to
.equal(1)
517 expect(videos
[0].name
).to
.equal(videosListBase
[5].name
)
523 it('Should search the first video', function (done
) {
524 videosUtils
.searchVideoWithPagination(server
.url
, 'webm', 'name', 0, 1, 'name', function (err
, res
) {
527 const videos
= res
.body
.data
528 expect(res
.body
.total
).to
.equal(4)
529 expect(videos
.length
).to
.equal(1)
530 expect(videos
[0].name
).to
.equal('video_short1.webm name')
536 it('Should search the last two videos', function (done
) {
537 videosUtils
.searchVideoWithPagination(server
.url
, 'webm', 'name', 2, 2, 'name', function (err
, res
) {
540 const videos
= res
.body
.data
541 expect(res
.body
.total
).to
.equal(4)
542 expect(videos
.length
).to
.equal(2)
543 expect(videos
[0].name
).to
.equal('video_short3.webm name')
544 expect(videos
[1].name
).to
.equal('video_short.webm name')
550 it('Should search all the webm videos', function (done
) {
551 videosUtils
.searchVideoWithPagination(server
.url
, 'webm', 'name', 0, 15, function (err
, res
) {
554 const videos
= res
.body
.data
555 expect(res
.body
.total
).to
.equal(4)
556 expect(videos
.length
).to
.equal(4)
562 it('Should search all the root author videos', function (done
) {
563 videosUtils
.searchVideoWithPagination(server
.url
, 'root', 'author', 0, 15, function (err
, res
) {
566 const videos
= res
.body
.data
567 expect(res
.body
.total
).to
.equal(6)
568 expect(videos
.length
).to
.equal(6)
574 // Not implemented yet
575 // it('Should search all the 9001 port videos', function (done) {
576 // videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15, function (err, res) {
577 // if (err) throw err
579 // const videos = res.body.data
580 // expect(res.body.total).to.equal(6)
581 // expect(videos.length).to.equal(6)
587 // it('Should search all the localhost videos', function (done) {
588 // videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15, function (err, res) {
589 // if (err) throw err
591 // const videos = res.body.data
592 // expect(res.body.total).to.equal(6)
593 // expect(videos.length).to.equal(6)
599 it('Should search the right magnetUri video', function (done
) {
600 const video
= videosListBase
[0]
601 videosUtils
.searchVideoWithPagination(server
.url
, encodeURIComponent(video
.files
[0].magnetUri
), 'magnetUri', 0, 15, function (err
, res
) {
604 const videos
= res
.body
.data
605 expect(res
.body
.total
).to
.equal(1)
606 expect(videos
.length
).to
.equal(1)
607 expect(videos
[0].name
).to
.equal(video
.name
)
613 it('Should list and sort by name in descending order', function (done
) {
614 videosUtils
.getVideosListSort(server
.url
, '-name', function (err
, res
) {
617 const videos
= res
.body
.data
618 expect(res
.body
.total
).to
.equal(6)
619 expect(videos
.length
).to
.equal(6)
620 expect(videos
[0].name
).to
.equal('video_short.webm name')
621 expect(videos
[1].name
).to
.equal('video_short.ogv name')
622 expect(videos
[2].name
).to
.equal('video_short.mp4 name')
623 expect(videos
[3].name
).to
.equal('video_short3.webm name')
624 expect(videos
[4].name
).to
.equal('video_short2.webm name')
625 expect(videos
[5].name
).to
.equal('video_short1.webm name')
631 it('Should search and sort by name in ascending order', function (done
) {
632 videosUtils
.searchVideoWithSort(server
.url
, 'webm', 'name', function (err
, res
) {
635 const videos
= res
.body
.data
636 expect(res
.body
.total
).to
.equal(4)
637 expect(videos
.length
).to
.equal(4)
639 expect(videos
[0].name
).to
.equal('video_short1.webm name')
640 expect(videos
[1].name
).to
.equal('video_short2.webm name')
641 expect(videos
[2].name
).to
.equal('video_short3.webm name')
642 expect(videos
[3].name
).to
.equal('video_short.webm name')
644 videoId
= videos
[2].id
650 it('Should update a video', function (done
) {
652 name: 'my super video updated',
657 description: 'my super description updated',
658 tags: [ 'tagup1', 'tagup2' ]
660 videosUtils
.updateVideo(server
.url
, server
.accessToken
, videoId
, attributes
, done
)
663 it('Should have the video updated', function (done
) {
666 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
669 const video
= res
.body
671 expect(video
.name
).to
.equal('my super video updated')
672 expect(video
.category
).to
.equal(4)
673 expect(video
.categoryLabel
).to
.equal('Art')
674 expect(video
.licence
).to
.equal(2)
675 expect(video
.licenceLabel
).to
.equal('Attribution - Share Alike')
676 expect(video
.language
).to
.equal(5)
677 expect(video
.languageLabel
).to
.equal('Arabic')
678 expect(video
.nsfw
).to
.be
.ok
679 expect(video
.description
).to
.equal('my super description updated')
680 expect(video
.podHost
).to
.equal('localhost:9001')
681 expect(video
.author
).to
.equal('root')
682 expect(video
.isLocal
).to
.be
.true
683 expect(video
.tags
).to
.deep
.equal([ 'tagup1', 'tagup2' ])
684 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
685 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
687 expect(video
.files
).to
.have
.lengthOf(1)
689 const file
= video
.files
[0]
690 const magnetUri
= file
.magnetUri
691 expect(file
.magnetUri
).to
.exist
692 expect(file
.resolution
).to
.equal(0)
693 expect(file
.resolutionLabel
).to
.equal('original')
694 expect(file
.size
).to
.equal(292677)
696 videosUtils
.testVideoImage(server
.url
, 'video_short3.webm', video
.thumbnailPath
, function (err
, test
) {
698 expect(test
).to
.equal(true)
700 webtorrent
.add(magnetUri
, function (torrent
) {
701 expect(torrent
.files
).to
.exist
702 expect(torrent
.files
.length
).to
.equal(1)
703 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
711 it('Should update only the tags of a video', function (done
) {
713 tags: [ 'tag1', 'tag2', 'supertag' ]
716 videosUtils
.updateVideo(server
.url
, server
.accessToken
, videoId
, attributes
, function (err
) {
719 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
722 const video
= res
.body
724 expect(video
.name
).to
.equal('my super video updated')
725 expect(video
.category
).to
.equal(4)
726 expect(video
.categoryLabel
).to
.equal('Art')
727 expect(video
.licence
).to
.equal(2)
728 expect(video
.licenceLabel
).to
.equal('Attribution - Share Alike')
729 expect(video
.language
).to
.equal(5)
730 expect(video
.languageLabel
).to
.equal('Arabic')
731 expect(video
.nsfw
).to
.be
.ok
732 expect(video
.description
).to
.equal('my super description updated')
733 expect(video
.podHost
).to
.equal('localhost:9001')
734 expect(video
.author
).to
.equal('root')
735 expect(video
.isLocal
).to
.be
.true
736 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'supertag' ])
737 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
738 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
740 expect(video
.files
).to
.have
.lengthOf(1)
742 const file
= video
.files
[0]
743 const magnetUri
= file
.magnetUri
744 expect(file
.magnetUri
).to
.exist
745 expect(file
.resolution
).to
.equal(0)
746 expect(file
.resolutionLabel
).to
.equal('original')
747 expect(file
.size
).to
.equal(292677)
754 it('Should update only the description of a video', function (done
) {
756 description: 'hello everybody'
759 videosUtils
.updateVideo(server
.url
, server
.accessToken
, videoId
, attributes
, function (err
) {
762 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
765 const video
= res
.body
767 expect(video
.name
).to
.equal('my super video updated')
768 expect(video
.category
).to
.equal(4)
769 expect(video
.categoryLabel
).to
.equal('Art')
770 expect(video
.licence
).to
.equal(2)
771 expect(video
.licenceLabel
).to
.equal('Attribution - Share Alike')
772 expect(video
.language
).to
.equal(5)
773 expect(video
.languageLabel
).to
.equal('Arabic')
774 expect(video
.nsfw
).to
.be
.ok
775 expect(video
.description
).to
.equal('hello everybody')
776 expect(video
.podHost
).to
.equal('localhost:9001')
777 expect(video
.author
).to
.equal('root')
778 expect(video
.isLocal
).to
.be
.true
779 expect(video
.tags
).to
.deep
.equal([ 'tag1', 'tag2', 'supertag' ])
780 expect(miscsUtils
.dateIsValid(video
.createdAt
)).to
.be
.true
781 expect(miscsUtils
.dateIsValid(video
.updatedAt
)).to
.be
.true
783 expect(video
.files
).to
.have
.lengthOf(1)
785 const file
= video
.files
[0]
786 const magnetUri
= file
.magnetUri
787 expect(file
.magnetUri
).to
.exist
788 expect(file
.resolution
).to
.equal(0)
789 expect(file
.resolutionLabel
).to
.equal('original')
790 expect(file
.size
).to
.equal(292677)
797 it('Should like a video', function (done
) {
798 videosUtils
.rateVideo(server
.url
, server
.accessToken
, videoId
, 'like', function (err
) {
801 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
804 const video
= res
.body
806 expect(video
.likes
).to
.equal(1)
807 expect(video
.dislikes
).to
.equal(0)
814 it('Should dislike the same video', function (done
) {
815 videosUtils
.rateVideo(server
.url
, server
.accessToken
, videoId
, 'dislike', function (err
) {
818 videosUtils
.getVideo(server
.url
, videoId
, function (err
, res
) {
821 const video
= res
.body
823 expect(video
.likes
).to
.equal(0)
824 expect(video
.dislikes
).to
.equal(1)
831 after(function (done
) {
832 process
.kill(-server
.app
.pid
)
834 // Keep the logs if the test failed
836 serversUtils
.flushTests(done
)