aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/users.js8
-rw-r--r--server/tests/api/check-params/video-abuses.js8
-rw-r--r--server/tests/api/friends-advanced.js10
-rw-r--r--server/tests/api/index.js1
-rw-r--r--server/tests/api/multiple-pods.js68
-rw-r--r--server/tests/api/requests.js26
-rw-r--r--server/tests/api/single-pod.js51
-rw-r--r--server/tests/api/users.js32
-rw-r--r--server/tests/api/video-abuse.js22
-rw-r--r--server/tests/real-world/real-world.js25
-rw-r--r--server/tests/real-world/tools/upload.js11
-rw-r--r--server/tests/utils/videos.js42
12 files changed, 158 insertions, 146 deletions
diff --git a/server/tests/api/check-params/users.js b/server/tests/api/check-params/users.js
index f6fbcf555..b04f9f4a6 100644
--- a/server/tests/api/check-params/users.js
+++ b/server/tests/api/check-params/users.js
@@ -50,12 +50,8 @@ describe('Test users API validators', function () {
50 usersUtils.createUser(server.url, server.accessToken, username, password, next) 50 usersUtils.createUser(server.url, server.accessToken, username, password, next)
51 }, 51 },
52 function (next) { 52 function (next) {
53 const name = 'my super name for pod' 53 const videoAttributes = {}
54 const category = 5 54 videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next)
55 const description = 'my super description for pod'
56 const tags = [ 'tag' ]
57 const file = 'video_short2.webm'
58 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
59 }, 55 },
60 function (next) { 56 function (next) {
61 videosUtils.getVideosList(server.url, function (err, res) { 57 videosUtils.getVideosList(server.url, function (err, res) {
diff --git a/server/tests/api/check-params/video-abuses.js b/server/tests/api/check-params/video-abuses.js
index 061b80be8..6dc5a7090 100644
--- a/server/tests/api/check-params/video-abuses.js
+++ b/server/tests/api/check-params/video-abuses.js
@@ -61,12 +61,8 @@ describe('Test video abuses API validators', function () {
61 }, 61 },
62 // Upload some videos on each pods 62 // Upload some videos on each pods
63 function (next) { 63 function (next) {
64 const name = 'my super name for pod' 64 const videoAttributes = {}
65 const category = 2 65 videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next)
66 const description = 'my super description for pod'
67 const tags = [ 'tag' ]
68 const file = 'video_short2.webm'
69 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, next)
70 }, 66 },
71 function (next) { 67 function (next) {
72 videosUtils.getVideosList(server.url, function (err, res) { 68 videosUtils.getVideosList(server.url, function (err, res) {
diff --git a/server/tests/api/friends-advanced.js b/server/tests/api/friends-advanced.js
index 584c38c24..afa699914 100644
--- a/server/tests/api/friends-advanced.js
+++ b/server/tests/api/friends-advanced.js
@@ -31,14 +31,12 @@ describe('Test advanced friends', function () {
31 } 31 }
32 32
33 function uploadVideo (podNumber, callback) { 33 function uploadVideo (podNumber, callback) {
34 const name = 'my super video' 34 const videoAttributes = {
35 const category = 5 35 tags: [ 'tag1', 'tag2' ]
36 const description = 'my super description' 36 }
37 const tags = [ 'tag1', 'tag2' ]
38 const fixture = 'video_short.webm'
39 const server = servers[podNumber - 1] 37 const server = servers[podNumber - 1]
40 38
41 return videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback) 39 return videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callback)
42 } 40 }
43 41
44 function getVideos (podNumber, callback) { 42 function getVideos (podNumber, callback) {
diff --git a/server/tests/api/index.js b/server/tests/api/index.js
index dc6ef92ab..fcd12617e 100644
--- a/server/tests/api/index.js
+++ b/server/tests/api/index.js
@@ -7,4 +7,5 @@ require('./friends-basic')
7require('./users') 7require('./users')
8require('./single-pod') 8require('./single-pod')
9require('./multiple-pods') 9require('./multiple-pods')
10require('./requests')
10require('./friends-advanced') 11require('./friends-advanced')
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index eccc9ecef..d5c723b3b 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -80,12 +80,13 @@ describe('Test multiple pods', function () {
80 80
81 series([ 81 series([
82 function (next) { 82 function (next) {
83 const name = 'my super name for pod 1' 83 const videoAttributes = {
84 const category = 5 84 name: 'my super name for pod 1',
85 const description = 'my super description for pod 1' 85 description: 'my super description for pod 1',
86 const tags = [ 'tag1p1', 'tag2p1' ] 86 tags: [ 'tag1p1', 'tag2p1' ],
87 const file = 'video_short1.webm' 87 fixture: 'video_short1.webm'
88 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next) 88 }
89 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, next)
89 }, 90 },
90 function (next) { 91 function (next) {
91 setTimeout(next, 11000) 92 setTimeout(next, 11000)
@@ -146,12 +147,14 @@ describe('Test multiple pods', function () {
146 147
147 series([ 148 series([
148 function (next) { 149 function (next) {
149 const name = 'my super name for pod 2' 150 const videoAttributes = {
150 const category = 4 151 name: 'my super name for pod 2',
151 const description = 'my super description for pod 2' 152 category: 4,
152 const tags = [ 'tag1p2', 'tag2p2', 'tag3p2' ] 153 description: 'my super description for pod 2',
153 const file = 'video_short2.webm' 154 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
154 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next) 155 fixture: 'video_short2.webm'
156 }
157 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
155 }, 158 },
156 function (next) { 159 function (next) {
157 setTimeout(next, 11000) 160 setTimeout(next, 11000)
@@ -212,20 +215,24 @@ describe('Test multiple pods', function () {
212 215
213 series([ 216 series([
214 function (next) { 217 function (next) {
215 const name = 'my super name for pod 3' 218 const videoAttributes = {
216 const category = 6 219 name: 'my super name for pod 3',
217 const description = 'my super description for pod 3' 220 category: 6,
218 const tags = [ 'tag1p3' ] 221 description: 'my super description for pod 3',
219 const file = 'video_short3.webm' 222 tags: [ 'tag1p3' ],
220 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next) 223 fixture: 'video_short3.webm'
224 }
225 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes, next)
221 }, 226 },
222 function (next) { 227 function (next) {
223 const name = 'my super name for pod 3-2' 228 const videoAttributes = {
224 const category = 7 229 name: 'my super name for pod 3-2',
225 const description = 'my super description for pod 3-2' 230 category: 7,
226 const tags = [ 'tag2p3', 'tag3p3', 'tag4p3' ] 231 description: 'my super description for pod 3-2',
227 const file = 'video_short.webm' 232 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
228 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, name, category, description, tags, file, next) 233 fixture: 'video_short.webm'
234 }
235 videosUtils.uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes, next)
229 }, 236 },
230 function (next) { 237 function (next) {
231 setTimeout(next, 22000) 238 setTimeout(next, 22000)
@@ -614,12 +621,13 @@ describe('Test multiple pods', function () {
614 it('Should update the video 3 by asking pod 3', function (done) { 621 it('Should update the video 3 by asking pod 3', function (done) {
615 this.timeout(15000) 622 this.timeout(15000)
616 623
617 const name = 'my super video updated' 624 const attributes = {
618 const category = 10 625 name: 'my super video updated',
619 const description = 'my super description updated' 626 category: 10,
620 const tags = [ 'tagup1', 'tagup2' ] 627 description: 'my super description updated',
621 628 tags: [ 'tagup1', 'tagup2' ]
622 videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, name, category, description, tags, function (err) { 629 }
630 videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes, function (err) {
623 if (err) throw err 631 if (err) throw err
624 632
625 setTimeout(done, 11000) 633 setTimeout(done, 11000)
diff --git a/server/tests/api/requests.js b/server/tests/api/requests.js
index b4b8393e3..8762163af 100644
--- a/server/tests/api/requests.js
+++ b/server/tests/api/requests.js
@@ -13,17 +13,16 @@ const serversUtils = require('../utils/servers')
13const videosUtils = require('../utils/videos') 13const videosUtils = require('../utils/videos')
14 14
15describe('Test requests stats', function () { 15describe('Test requests stats', function () {
16 const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ]
16 const path = '/api/v1/requests/stats' 17 const path = '/api/v1/requests/stats'
17 let servers = [] 18 let servers = []
18 19
19 function uploadVideo (server, callback) { 20 function uploadVideo (server, callback) {
20 const name = 'my super video' 21 const videoAttributes = {
21 const category = 5 22 tags: [ 'tag1', 'tag2' ]
22 const description = 'my super description' 23 }
23 const tags = [ 'tag1', 'tag2' ]
24 const fixture = 'video_short.webm'
25 24
26 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, fixture, callback) 25 videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callback)
27 } 26 }
28 27
29 function getRequestsStats (server, callback) { 28 function getRequestsStats (server, callback) {
@@ -64,9 +63,13 @@ describe('Test requests stats', function () {
64 getRequestsStats(server, function (err, res) { 63 getRequestsStats(server, function (err, res) {
65 if (err) throw err 64 if (err) throw err
66 65
67 const body = res.body 66 const requestSchedulers = res.body
68 expect(body.remainingMilliSeconds).to.be.at.least(0) 67 for (const requestSchedulerName of requestSchedulerNames) {
69 expect(body.remainingMilliSeconds).to.be.at.most(10000) 68 const requestScheduler = requestSchedulers[requestSchedulerName]
69
70 expect(requestScheduler.remainingMilliSeconds).to.be.at.least(0)
71 expect(requestScheduler.remainingMilliSeconds).to.be.at.most(10000)
72 }
70 73
71 done() 74 done()
72 }) 75 })
@@ -86,8 +89,9 @@ describe('Test requests stats', function () {
86 getRequestsStats(server, function (err, res) { 89 getRequestsStats(server, function (err, res) {
87 if (err) throw err 90 if (err) throw err
88 91
89 const body = res.body 92 const requestSchedulers = res.body
90 expect(body.totalRequests).to.equal(1) 93 const requestScheduler = requestSchedulers.requestScheduler
94 expect(requestScheduler.totalRequests).to.equal(1)
91 95
92 done() 96 done()
93 }) 97 })
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index d583592d8..9465f6034 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -70,13 +70,12 @@ describe('Test a single pod', function () {
70 }) 70 })
71 71
72 it('Should upload the video', function (done) { 72 it('Should upload the video', function (done) {
73 this.timeout(5000) 73 const videoAttributes = {
74 const name = 'my super name' 74 name: 'my super name',
75 const description = 'my super description' 75 category: 2,
76 const category = 2 76 tags: [ 'tag1', 'tag2', 'tag3' ]
77 const tags = [ 'tag1', 'tag2', 'tag3' ] 77 }
78 const file = 'video_short.webm' 78 videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, done)
79 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, file, done)
80 }) 79 })
81 80
82 it('Should seed the uploaded video', function (done) { 81 it('Should seed the uploaded video', function (done) {
@@ -321,12 +320,15 @@ describe('Test a single pod', function () {
321 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' 320 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
322 ] 321 ]
323 each(videos, function (video, callbackEach) { 322 each(videos, function (video, callbackEach) {
324 const name = video + ' name' 323 const videoAttributes = {
325 const description = video + ' description' 324 name: video + ' name',
326 const category = 2 325 description: video + ' description',
327 const tags = [ 'tag1', 'tag2', 'tag3' ] 326 category: 2,
327 tags: [ 'tag1', 'tag2', 'tag3' ],
328 fixture: video
329 }
328 330
329 videosUtils.uploadVideo(server.url, server.accessToken, name, category, description, tags, video, callbackEach) 331 videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, callbackEach)
330 }, done) 332 }, done)
331 }) 333 })
332 334
@@ -543,12 +545,13 @@ describe('Test a single pod', function () {
543 }) 545 })
544 546
545 it('Should update a video', function (done) { 547 it('Should update a video', function (done) {
546 const name = 'my super video updated' 548 const attributes = {
547 const category = 4 549 name: 'my super video updated',
548 const description = 'my super description updated' 550 category: 4,
549 const tags = [ 'tagup1', 'tagup2' ] 551 description: 'my super description updated',
550 552 tags: [ 'tagup1', 'tagup2' ]
551 videosUtils.updateVideo(server.url, server.accessToken, videoId, name, category, description, tags, done) 553 }
554 videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, done)
552 }) 555 })
553 556
554 it('Should have the video updated', function (done) { 557 it('Should have the video updated', function (done) {
@@ -586,9 +589,11 @@ describe('Test a single pod', function () {
586 }) 589 })
587 590
588 it('Should update only the tags of a video', function (done) { 591 it('Should update only the tags of a video', function (done) {
589 const tags = [ 'tag1', 'tag2', 'supertag' ] 592 const attributes = {
593 tags: [ 'tag1', 'tag2', 'supertag' ]
594 }
590 595
591 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, null, tags, function (err) { 596 videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
592 if (err) throw err 597 if (err) throw err
593 598
594 videosUtils.getVideo(server.url, videoId, function (err, res) { 599 videosUtils.getVideo(server.url, videoId, function (err, res) {
@@ -613,9 +618,11 @@ describe('Test a single pod', function () {
613 }) 618 })
614 619
615 it('Should update only the description of a video', function (done) { 620 it('Should update only the description of a video', function (done) {
616 const description = 'hello everybody' 621 const attributes = {
622 description: 'hello everybody'
623 }
617 624
618 videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, description, null, function (err) { 625 videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
619 if (err) throw err 626 if (err) throw err
620 627
621 videosUtils.getVideo(server.url, videoId, function (err, res) { 628 videosUtils.getVideo(server.url, videoId, function (err, res) {
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index 0f062c11f..2b6956baa 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -85,12 +85,8 @@ describe('Test users', function () {
85 it('Should not be able to upload a video', function (done) { 85 it('Should not be able to upload a video', function (done) {
86 accessToken = 'mysupertoken' 86 accessToken = 'mysupertoken'
87 87
88 const name = 'my super name' 88 const videoAttributes = {}
89 const description = 'my super description' 89 videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 401, done)
90 const category = 5
91 const tags = [ 'tag1', 'tag2' ]
92 const video = 'video_short.webm'
93 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 401, done)
94 }) 90 })
95 91
96 it('Should not be able to make friends', function (done) { 92 it('Should not be able to make friends', function (done) {
@@ -113,12 +109,8 @@ describe('Test users', function () {
113 }) 109 })
114 110
115 it('Should upload the video with the correct token', function (done) { 111 it('Should upload the video with the correct token', function (done) {
116 const name = 'my super name' 112 const videoAttributes = {}
117 const category = 5 113 videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 204, function (err, res) {
118 const description = 'my super description'
119 const tags = [ 'tag1', 'tag2' ]
120 const video = 'video_short.webm'
121 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, function (err, res) {
122 if (err) throw err 114 if (err) throw err
123 115
124 videosUtils.getVideosList(server.url, function (err, res) { 116 videosUtils.getVideosList(server.url, function (err, res) {
@@ -134,12 +126,8 @@ describe('Test users', function () {
134 }) 126 })
135 127
136 it('Should upload the video again with the correct token', function (done) { 128 it('Should upload the video again with the correct token', function (done) {
137 const name = 'my super name 2' 129 const videoAttributes = {}
138 const category = 5 130 videosUtils.uploadVideo(server.url, accessToken, videoAttributes, 204, done)
139 const description = 'my super description 2'
140 const tags = [ 'tag1' ]
141 const video = 'video_short.webm'
142 videosUtils.uploadVideo(server.url, accessToken, name, category, description, tags, video, 204, done)
143 }) 131 })
144 132
145 it('Should retrieve a video rating', function (done) { 133 it('Should retrieve a video rating', function (done) {
@@ -230,12 +218,8 @@ describe('Test users', function () {
230 it('Should be able to upload a video with this user', function (done) { 218 it('Should be able to upload a video with this user', function (done) {
231 this.timeout(5000) 219 this.timeout(5000)
232 220
233 const name = 'my super name' 221 const videoAttributes = {}
234 const category = 5 222 videosUtils.uploadVideo(server.url, accessTokenUser, videoAttributes, done)
235 const description = 'my super description'
236 const tags = [ 'tag1', 'tag2', 'tag3' ]
237 const file = 'video_short.webm'
238 videosUtils.uploadVideo(server.url, accessTokenUser, name, category, description, tags, file, done)
239 }) 223 })
240 224
241 it('Should list all the users', function (done) { 225 it('Should list all the users', function (done) {
diff --git a/server/tests/api/video-abuse.js b/server/tests/api/video-abuse.js
index 871054788..7db067585 100644
--- a/server/tests/api/video-abuse.js
+++ b/server/tests/api/video-abuse.js
@@ -45,20 +45,18 @@ describe('Test video abuses', function () {
45 }, 45 },
46 // Upload some videos on each pods 46 // Upload some videos on each pods
47 function (next) { 47 function (next) {
48 const name = 'my super name for pod 1' 48 const videoAttributes = {
49 const category = 5 49 name: 'my super name for pod 1',
50 const description = 'my super description for pod 1' 50 description: 'my super description for pod 1'
51 const tags = [ 'tag' ] 51 }
52 const file = 'video_short2.webm' 52 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, next)
53 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, name, category, description, tags, file, next)
54 }, 53 },
55 function (next) { 54 function (next) {
56 const name = 'my super name for pod 2' 55 const videoAttributes = {
57 const category = 5 56 name: 'my super name for pod 2',
58 const description = 'my super description for pod 2' 57 description: 'my super description for pod 2'
59 const tags = [ 'tag' ] 58 }
60 const file = 'video_short2.webm' 59 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
61 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, name, category, description, tags, file, next)
62 }, 60 },
63 // Wait videos propagation 61 // Wait videos propagation
64 function (next) { 62 function (next) {
diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js
index f17c83f85..32afeec68 100644
--- a/server/tests/real-world/real-world.js
+++ b/server/tests/real-world/real-world.js
@@ -200,15 +200,16 @@ function exitServers (servers, callback) {
200function upload (servers, numServer, callback) { 200function upload (servers, numServer, callback) {
201 if (!callback) callback = function () {} 201 if (!callback) callback = function () {}
202 202
203 const name = Date.now() + ' name'
204 const category = 4
205 const description = Date.now() + ' description'
206 const tags = [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
207 const file = 'video_short1.webm'
208
209 console.log('Uploading video to server ' + numServer) 203 console.log('Uploading video to server ' + numServer)
210 204
211 videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, name, category, description, tags, file, callback) 205 const videoAttributes = {
206 name: Date.now() + ' name',
207 category: 4,
208 description: Date.now() + ' description',
209 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ],
210 fixture: 'video_short1.webm'
211 }
212 videosUtils.uploadVideo(servers[numServer].url, servers[numServer].accessToken, videoAttributes, callback)
212} 213}
213 214
214function update (servers, numServer, callback) { 215function update (servers, numServer, callback) {
@@ -221,13 +222,15 @@ function update (servers, numServer, callback) {
221 if (videos.length === 0) return callback() 222 if (videos.length === 0) return callback()
222 223
223 const toUpdate = videos[getRandomInt(0, videos.length)].id 224 const toUpdate = videos[getRandomInt(0, videos.length)].id
224 const name = Date.now() + ' name' 225 const attributes = {
225 const description = Date.now() + ' description' 226 name: Date.now() + ' name',
226 const tags = [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ] 227 description: Date.now() + ' description',
228 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
229 }
227 230
228 console.log('Updating video of server ' + numServer) 231 console.log('Updating video of server ' + numServer)
229 232
230 videosUtils.updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, name, description, tags, callback) 233 videosUtils.updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, attributes, callback)
231 }) 234 })
232} 235}
233 236
diff --git a/server/tests/real-world/tools/upload.js b/server/tests/real-world/tools/upload.js
index 49076ee2a..856251c7f 100644
--- a/server/tests/real-world/tools/upload.js
+++ b/server/tests/real-world/tools/upload.js
@@ -49,10 +49,17 @@ function list (val) {
49 return val.split(',') 49 return val.split(',')
50} 50}
51 51
52function upload (url, accessToken, name, category, description, tags, file) { 52function upload (url, accessToken, name, category, description, tags, fixture) {
53 console.log('Uploading %s video...', program.name) 53 console.log('Uploading %s video...', program.name)
54 54
55 utils.uploadVideo(url, accessToken, name, category, description, tags, file, function (err) { 55 const videoAttributes = {
56 name,
57 category,
58 description,
59 tags,
60 fixture
61 }
62 utils.uploadVideo(url, accessToken, videoAttributes, function (err) {
56 if (err) throw err 63 if (err) throw err
57 64
58 console.log('Video uploaded.') 65 console.log('Video uploaded.')
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js
index 0aa6ec5a8..ad0d74076 100644
--- a/server/tests/utils/videos.js
+++ b/server/tests/utils/videos.js
@@ -193,7 +193,7 @@ function testVideoImage (url, videoName, imagePath, callback) {
193 } 193 }
194} 194}
195 195
196function uploadVideo (url, accessToken, name, category, description, tags, fixture, specialStatus, end) { 196function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end) {
197 if (!end) { 197 if (!end) {
198 end = specialStatus 198 end = specialStatus
199 specialStatus = 204 199 specialStatus = 204
@@ -201,23 +201,33 @@ function uploadVideo (url, accessToken, name, category, description, tags, fixtu
201 201
202 const path = '/api/v1/videos' 202 const path = '/api/v1/videos'
203 203
204 // Default attributes
205 let attributes = {
206 name: 'my super video',
207 category: 5,
208 description: 'my super description',
209 tags: [ 'tag' ],
210 fixture: 'video_short.webm'
211 }
212 attributes = Object.assign(attributes, videoAttributesArg)
213
204 const req = request(url) 214 const req = request(url)
205 .post(path) 215 .post(path)
206 .set('Accept', 'application/json') 216 .set('Accept', 'application/json')
207 .set('Authorization', 'Bearer ' + accessToken) 217 .set('Authorization', 'Bearer ' + accessToken)
208 .field('name', name) 218 .field('name', attributes.name)
209 .field('category', category) 219 .field('category', attributes.category)
210 .field('description', description) 220 .field('description', attributes.description)
211 221
212 for (let i = 0; i < tags.length; i++) { 222 for (let i = 0; i < attributes.tags.length; i++) {
213 req.field('tags[' + i + ']', tags[i]) 223 req.field('tags[' + i + ']', attributes.tags[i])
214 } 224 }
215 225
216 let filepath = '' 226 let filepath = ''
217 if (pathUtils.isAbsolute(fixture)) { 227 if (pathUtils.isAbsolute(attributes.fixture)) {
218 filepath = fixture 228 filepath = attributes.fixture
219 } else { 229 } else {
220 filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', fixture) 230 filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', attributes.fixture)
221 } 231 }
222 232
223 req.attach('videofile', filepath) 233 req.attach('videofile', filepath)
@@ -225,7 +235,7 @@ function uploadVideo (url, accessToken, name, category, description, tags, fixtu
225 .end(end) 235 .end(end)
226} 236}
227 237
228function updateVideo (url, accessToken, id, name, category, description, tags, specialStatus, end) { 238function updateVideo (url, accessToken, id, attributes, specialStatus, end) {
229 if (!end) { 239 if (!end) {
230 end = specialStatus 240 end = specialStatus
231 specialStatus = 204 241 specialStatus = 204
@@ -238,13 +248,13 @@ function updateVideo (url, accessToken, id, name, category, description, tags, s
238 .set('Accept', 'application/json') 248 .set('Accept', 'application/json')
239 .set('Authorization', 'Bearer ' + accessToken) 249 .set('Authorization', 'Bearer ' + accessToken)
240 250
241 if (name) req.field('name', name) 251 if (attributes.name) req.field('name', attributes.name)
242 if (category) req.field('category', category) 252 if (attributes.category) req.field('category', attributes.category)
243 if (description) req.field('description', description) 253 if (attributes.description) req.field('description', attributes.description)
244 254
245 if (tags) { 255 if (attributes.tags) {
246 for (let i = 0; i < tags.length; i++) { 256 for (let i = 0; i < attributes.tags.length; i++) {
247 req.field('tags[' + i + ']', tags[i]) 257 req.field('tags[' + i + ']', attributes.tags[i])
248 } 258 }
249 } 259 }
250 260