diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/users.js | 8 | ||||
-rw-r--r-- | server/tests/api/check-params/video-abuses.js | 8 | ||||
-rw-r--r-- | server/tests/api/friends-advanced.js | 10 | ||||
-rw-r--r-- | server/tests/api/index.js | 1 | ||||
-rw-r--r-- | server/tests/api/multiple-pods.js | 68 | ||||
-rw-r--r-- | server/tests/api/requests.js | 26 | ||||
-rw-r--r-- | server/tests/api/single-pod.js | 51 | ||||
-rw-r--r-- | server/tests/api/users.js | 32 | ||||
-rw-r--r-- | server/tests/api/video-abuse.js | 22 |
9 files changed, 109 insertions, 117 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') | |||
7 | require('./users') | 7 | require('./users') |
8 | require('./single-pod') | 8 | require('./single-pod') |
9 | require('./multiple-pods') | 9 | require('./multiple-pods') |
10 | require('./requests') | ||
10 | require('./friends-advanced') | 11 | require('./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') | |||
13 | const videosUtils = require('../utils/videos') | 13 | const videosUtils = require('../utils/videos') |
14 | 14 | ||
15 | describe('Test requests stats', function () { | 15 | describe('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) { |