diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-09 11:06:13 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-09 11:17:36 +0200 |
commit | 14d3270f363245d2c83fcc2ac109e39743b5627e (patch) | |
tree | 22a1d40675d372d53c35a4d7adf1fc1b4ceb1799 /server/tests | |
parent | aa8b6df4a51c82eb91e6fd71a090b2128098af6b (diff) | |
download | PeerTube-14d3270f363245d2c83fcc2ac109e39743b5627e.tar.gz PeerTube-14d3270f363245d2c83fcc2ac109e39743b5627e.tar.zst PeerTube-14d3270f363245d2c83fcc2ac109e39743b5627e.zip |
Change how we handle resolution
It was an enum before, now we just use video height
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/multiple-pods.ts | 41 | ||||
-rw-r--r-- | server/tests/api/single-pod.ts | 28 | ||||
-rw-r--r-- | server/tests/api/video-transcoder.ts | 2 | ||||
-rw-r--r-- | server/tests/cli/update-host.ts | 4 | ||||
-rw-r--r-- | server/tests/utils/videos.ts | 12 |
5 files changed, 49 insertions, 38 deletions
diff --git a/server/tests/api/multiple-pods.ts b/server/tests/api/multiple-pods.ts index 08fa73aa2..8b60ac0f4 100644 --- a/server/tests/api/multiple-pods.ts +++ b/server/tests/api/multiple-pods.ts | |||
@@ -106,8 +106,8 @@ describe('Test multiple pods', function () { | |||
106 | const file = video.files[0] | 106 | const file = video.files[0] |
107 | const magnetUri = file.magnetUri | 107 | const magnetUri = file.magnetUri |
108 | expect(file.magnetUri).to.have.lengthOf.above(2) | 108 | expect(file.magnetUri).to.have.lengthOf.above(2) |
109 | expect(file.resolution).to.equal(0) | 109 | expect(file.resolution).to.equal(720) |
110 | expect(file.resolutionLabel).to.equal('original') | 110 | expect(file.resolutionLabel).to.equal('720p') |
111 | expect(file.size).to.equal(572456) | 111 | expect(file.size).to.equal(572456) |
112 | 112 | ||
113 | if (server.url !== 'http://localhost:9001') { | 113 | if (server.url !== 'http://localhost:9001') { |
@@ -172,7 +172,7 @@ describe('Test multiple pods', function () { | |||
172 | expect(dateIsValid(video.updatedAt)).to.be.true | 172 | expect(dateIsValid(video.updatedAt)).to.be.true |
173 | expect(video.author).to.equal('root') | 173 | expect(video.author).to.equal('root') |
174 | 174 | ||
175 | expect(video.files).to.have.lengthOf(5) | 175 | expect(video.files).to.have.lengthOf(4) |
176 | 176 | ||
177 | // Check common attributes | 177 | // Check common attributes |
178 | for (const file of video.files) { | 178 | for (const file of video.files) { |
@@ -192,11 +192,6 @@ describe('Test multiple pods', function () { | |||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | const originalFile = video.files.find(f => f.resolution === 0) | ||
196 | expect(originalFile).not.to.be.undefined | ||
197 | expect(originalFile.resolutionLabel).to.equal('original') | ||
198 | expect(originalFile.size).to.be.above(700000).and.below(720000) | ||
199 | |||
200 | const file240p = video.files.find(f => f.resolution === 240) | 195 | const file240p = video.files.find(f => f.resolution === 240) |
201 | expect(file240p).not.to.be.undefined | 196 | expect(file240p).not.to.be.undefined |
202 | expect(file240p.resolutionLabel).to.equal('240p') | 197 | expect(file240p.resolutionLabel).to.equal('240p') |
@@ -215,7 +210,7 @@ describe('Test multiple pods', function () { | |||
215 | const file720p = video.files.find(f => f.resolution === 720) | 210 | const file720p = video.files.find(f => f.resolution === 720) |
216 | expect(file720p).not.to.be.undefined | 211 | expect(file720p).not.to.be.undefined |
217 | expect(file720p.resolutionLabel).to.equal('720p') | 212 | expect(file720p.resolutionLabel).to.equal('720p') |
218 | expect(file720p.size).to.be.above(310000).and.below(320000) | 213 | expect(file720p.size).to.be.above(700000).and.below(7200000) |
219 | 214 | ||
220 | const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath) | 215 | const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath) |
221 | expect(test).to.equal(true) | 216 | expect(test).to.equal(true) |
@@ -291,8 +286,8 @@ describe('Test multiple pods', function () { | |||
291 | 286 | ||
292 | const file1 = video1.files[0] | 287 | const file1 = video1.files[0] |
293 | expect(file1.magnetUri).to.have.lengthOf.above(2) | 288 | expect(file1.magnetUri).to.have.lengthOf.above(2) |
294 | expect(file1.resolution).to.equal(0) | 289 | expect(file1.resolution).to.equal(720) |
295 | expect(file1.resolutionLabel).to.equal('original') | 290 | expect(file1.resolutionLabel).to.equal('720p') |
296 | expect(file1.size).to.equal(292677) | 291 | expect(file1.size).to.equal(292677) |
297 | 292 | ||
298 | expect(video2.name).to.equal('my super name for pod 3-2') | 293 | expect(video2.name).to.equal('my super name for pod 3-2') |
@@ -316,8 +311,8 @@ describe('Test multiple pods', function () { | |||
316 | const file2 = video2.files[0] | 311 | const file2 = video2.files[0] |
317 | const magnetUri2 = file2.magnetUri | 312 | const magnetUri2 = file2.magnetUri |
318 | expect(file2.magnetUri).to.have.lengthOf.above(2) | 313 | expect(file2.magnetUri).to.have.lengthOf.above(2) |
319 | expect(file2.resolution).to.equal(0) | 314 | expect(file2.resolution).to.equal(720) |
320 | expect(file2.resolutionLabel).to.equal('original') | 315 | expect(file2.resolutionLabel).to.equal('720p') |
321 | expect(file2.size).to.equal(218910) | 316 | expect(file2.size).to.equal(218910) |
322 | 317 | ||
323 | if (server.url !== 'http://localhost:9003') { | 318 | if (server.url !== 'http://localhost:9003') { |
@@ -402,6 +397,22 @@ describe('Test multiple pods', function () { | |||
402 | expect(torrent.files.length).to.equal(1) | 397 | expect(torrent.files.length).to.equal(1) |
403 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 398 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
404 | }) | 399 | }) |
400 | |||
401 | it('Should add the file 2 in 360p by asking pod 1', async function () { | ||
402 | // Yes, this could be long | ||
403 | this.timeout(200000) | ||
404 | |||
405 | const res = await getVideosList(servers[0].url) | ||
406 | |||
407 | const video = res.body.data.find(v => v.name === 'my super name for pod 2') | ||
408 | const file = video.files.find(f => f.resolution === 360) | ||
409 | expect(file).not.to.be.undefined | ||
410 | |||
411 | const torrent = await webtorrentAdd(file.magnetUri) | ||
412 | expect(torrent.files).to.be.an('array') | ||
413 | expect(torrent.files.length).to.equal(1) | ||
414 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | ||
415 | }) | ||
405 | }) | 416 | }) |
406 | 417 | ||
407 | describe('Should update video views, likes and dislikes', function () { | 418 | describe('Should update video views, likes and dislikes', function () { |
@@ -562,8 +573,8 @@ describe('Test multiple pods', function () { | |||
562 | 573 | ||
563 | const file = videoUpdated.files[0] | 574 | const file = videoUpdated.files[0] |
564 | expect(file.magnetUri).to.have.lengthOf.above(2) | 575 | expect(file.magnetUri).to.have.lengthOf.above(2) |
565 | expect(file.resolution).to.equal(0) | 576 | expect(file.resolution).to.equal(720) |
566 | expect(file.resolutionLabel).to.equal('original') | 577 | expect(file.resolutionLabel).to.equal('720p') |
567 | expect(file.size).to.equal(292677) | 578 | expect(file.size).to.equal(292677) |
568 | 579 | ||
569 | const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath) | 580 | const test = await testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath) |
diff --git a/server/tests/api/single-pod.ts b/server/tests/api/single-pod.ts index 83c981f9b..82bc51a3e 100644 --- a/server/tests/api/single-pod.ts +++ b/server/tests/api/single-pod.ts | |||
@@ -127,8 +127,8 @@ describe('Test a single pod', function () { | |||
127 | const file = video.files[0] | 127 | const file = video.files[0] |
128 | const magnetUri = file.magnetUri | 128 | const magnetUri = file.magnetUri |
129 | expect(file.magnetUri).to.have.lengthOf.above(2) | 129 | expect(file.magnetUri).to.have.lengthOf.above(2) |
130 | expect(file.resolution).to.equal(0) | 130 | expect(file.resolution).to.equal(720) |
131 | expect(file.resolutionLabel).to.equal('original') | 131 | expect(file.resolutionLabel).to.equal('720p') |
132 | expect(file.size).to.equal(218910) | 132 | expect(file.size).to.equal(218910) |
133 | 133 | ||
134 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | 134 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
@@ -170,8 +170,8 @@ describe('Test a single pod', function () { | |||
170 | 170 | ||
171 | const file = video.files[0] | 171 | const file = video.files[0] |
172 | expect(file.magnetUri).to.have.lengthOf.above(2) | 172 | expect(file.magnetUri).to.have.lengthOf.above(2) |
173 | expect(file.resolution).to.equal(0) | 173 | expect(file.resolution).to.equal(720) |
174 | expect(file.resolutionLabel).to.equal('original') | 174 | expect(file.resolutionLabel).to.equal('720p') |
175 | expect(file.size).to.equal(218910) | 175 | expect(file.size).to.equal(218910) |
176 | 176 | ||
177 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | 177 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
@@ -229,8 +229,8 @@ describe('Test a single pod', function () { | |||
229 | 229 | ||
230 | const file = video.files[0] | 230 | const file = video.files[0] |
231 | expect(file.magnetUri).to.have.lengthOf.above(2) | 231 | expect(file.magnetUri).to.have.lengthOf.above(2) |
232 | expect(file.resolution).to.equal(0) | 232 | expect(file.resolution).to.equal(720) |
233 | expect(file.resolutionLabel).to.equal('original') | 233 | expect(file.resolutionLabel).to.equal('720p') |
234 | expect(file.size).to.equal(218910) | 234 | expect(file.size).to.equal(218910) |
235 | 235 | ||
236 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | 236 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
@@ -291,8 +291,8 @@ describe('Test a single pod', function () { | |||
291 | 291 | ||
292 | const file = video.files[0] | 292 | const file = video.files[0] |
293 | expect(file.magnetUri).to.have.lengthOf.above(2) | 293 | expect(file.magnetUri).to.have.lengthOf.above(2) |
294 | expect(file.resolution).to.equal(0) | 294 | expect(file.resolution).to.equal(720) |
295 | expect(file.resolutionLabel).to.equal('original') | 295 | expect(file.resolutionLabel).to.equal('720p') |
296 | expect(file.size).to.equal(218910) | 296 | expect(file.size).to.equal(218910) |
297 | 297 | ||
298 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | 298 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
@@ -569,8 +569,8 @@ describe('Test a single pod', function () { | |||
569 | const file = video.files[0] | 569 | const file = video.files[0] |
570 | const magnetUri = file.magnetUri | 570 | const magnetUri = file.magnetUri |
571 | expect(file.magnetUri).to.have.lengthOf.above(2) | 571 | expect(file.magnetUri).to.have.lengthOf.above(2) |
572 | expect(file.resolution).to.equal(0) | 572 | expect(file.resolution).to.equal(720) |
573 | expect(file.resolutionLabel).to.equal('original') | 573 | expect(file.resolutionLabel).to.equal('720p') |
574 | expect(file.size).to.equal(292677) | 574 | expect(file.size).to.equal(292677) |
575 | 575 | ||
576 | const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath) | 576 | const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath) |
@@ -612,8 +612,8 @@ describe('Test a single pod', function () { | |||
612 | 612 | ||
613 | const file = video.files[0] | 613 | const file = video.files[0] |
614 | expect(file.magnetUri).to.have.lengthOf.above(2) | 614 | expect(file.magnetUri).to.have.lengthOf.above(2) |
615 | expect(file.resolution).to.equal(0) | 615 | expect(file.resolution).to.equal(720) |
616 | expect(file.resolutionLabel).to.equal('original') | 616 | expect(file.resolutionLabel).to.equal('720p') |
617 | expect(file.size).to.equal(292677) | 617 | expect(file.size).to.equal(292677) |
618 | }) | 618 | }) |
619 | 619 | ||
@@ -647,8 +647,8 @@ describe('Test a single pod', function () { | |||
647 | 647 | ||
648 | const file = video.files[0] | 648 | const file = video.files[0] |
649 | expect(file.magnetUri).to.have.lengthOf.above(2) | 649 | expect(file.magnetUri).to.have.lengthOf.above(2) |
650 | expect(file.resolution).to.equal(0) | 650 | expect(file.resolution).to.equal(720) |
651 | expect(file.resolutionLabel).to.equal('original') | 651 | expect(file.resolutionLabel).to.equal('720p') |
652 | expect(file.size).to.equal(292677) | 652 | expect(file.size).to.equal(292677) |
653 | }) | 653 | }) |
654 | 654 | ||
diff --git a/server/tests/api/video-transcoder.ts b/server/tests/api/video-transcoder.ts index b5d84d9e7..22d89724b 100644 --- a/server/tests/api/video-transcoder.ts +++ b/server/tests/api/video-transcoder.ts | |||
@@ -68,7 +68,7 @@ describe('Test video transcoding', function () { | |||
68 | const res = await getVideosList(servers[1].url) | 68 | const res = await getVideosList(servers[1].url) |
69 | 69 | ||
70 | const video = res.body.data[0] | 70 | const video = res.body.data[0] |
71 | expect(video.files).to.have.lengthOf(5) | 71 | expect(video.files).to.have.lengthOf(4) |
72 | 72 | ||
73 | const magnetUri = video.files[0].magnetUri | 73 | const magnetUri = video.files[0].magnetUri |
74 | expect(magnetUri).to.match(/\.mp4/) | 74 | expect(magnetUri).to.match(/\.mp4/) |
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index e31a84156..7e1d3f658 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts | |||
@@ -55,13 +55,13 @@ describe('Test update host scripts', function () { | |||
55 | expect(videos).to.have.lengthOf(2) | 55 | expect(videos).to.have.lengthOf(2) |
56 | 56 | ||
57 | for (const video of videos) { | 57 | for (const video of videos) { |
58 | expect(video.files).to.have.lengthOf(5) | 58 | expect(video.files).to.have.lengthOf(4) |
59 | 59 | ||
60 | for (const file of video.files) { | 60 | for (const file of video.files) { |
61 | expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') | 61 | expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') |
62 | expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') | 62 | expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') |
63 | 63 | ||
64 | const torrent = await parseTorrentVideo(server, video.uuid, file.resolutionLabel) | 64 | const torrent = await parseTorrentVideo(server, video.uuid, file.resolution) |
65 | expect(torrent.announce[0]).to.equal('ws://localhost:9002/tracker/socket') | 65 | expect(torrent.announce[0]).to.equal('ws://localhost:9002/tracker/socket') |
66 | expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') | 66 | expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') |
67 | } | 67 | } |
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts index 7f8bd39c0..2a9a236ca 100644 --- a/server/tests/utils/videos.ts +++ b/server/tests/utils/videos.ts | |||
@@ -196,14 +196,14 @@ function uploadVideo (url: string, accessToken: string, videoAttributesArg: Vide | |||
196 | req.field('tags[' + i + ']', attributes.tags[i]) | 196 | req.field('tags[' + i + ']', attributes.tags[i]) |
197 | } | 197 | } |
198 | 198 | ||
199 | let filepath = '' | 199 | let filePath = '' |
200 | if (isAbsolute(attributes.fixture)) { | 200 | if (isAbsolute(attributes.fixture)) { |
201 | filepath = attributes.fixture | 201 | filePath = attributes.fixture |
202 | } else { | 202 | } else { |
203 | filepath = join(__dirname, '..', 'api', 'fixtures', attributes.fixture) | 203 | filePath = join(__dirname, '..', 'api', 'fixtures', attributes.fixture) |
204 | } | 204 | } |
205 | 205 | ||
206 | return req.attach('videofile', filepath) | 206 | return req.attach('videofile', filePath) |
207 | .expect(specialStatus) | 207 | .expect(specialStatus) |
208 | } | 208 | } |
209 | 209 | ||
@@ -238,9 +238,9 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string | |||
238 | .expect(specialStatus) | 238 | .expect(specialStatus) |
239 | } | 239 | } |
240 | 240 | ||
241 | function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolutionLabel: string) { | 241 | function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { |
242 | return new Promise<any>((res, rej) => { | 242 | return new Promise<any>((res, rej) => { |
243 | const torrentName = videoUUID + '-' + resolutionLabel + '.torrent' | 243 | const torrentName = videoUUID + '-' + resolution + '.torrent' |
244 | const torrentPath = join(__dirname, '..', '..', '..', 'test' + server.serverNumber, 'torrents', torrentName) | 244 | const torrentPath = join(__dirname, '..', '..', '..', 'test' + server.serverNumber, 'torrents', torrentName) |
245 | readFile(torrentPath, (err, data) => { | 245 | readFile(torrentPath, (err, data) => { |
246 | if (err) return rej(err) | 246 | if (err) return rej(err) |