aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-16 15:52:05 +0200
committerChocobozzz <me@florianbigard.com>2020-06-16 15:55:42 +0200
commit8eb07b01306429abe5c538ff7aa0a16e44fff26f (patch)
treeaa6461099e0652a54c9f49ecd5652f3ddfcc0fc1 /shared/extra-utils/videos/videos.ts
parent1ba471c55fdbf05ef2c10152b3e4b0c5d8da3213 (diff)
downloadPeerTube-8eb07b01306429abe5c538ff7aa0a16e44fff26f.tar.gz
PeerTube-8eb07b01306429abe5c538ff7aa0a16e44fff26f.tar.zst
PeerTube-8eb07b01306429abe5c538ff7aa0a16e44fff26f.zip
Split notification tests
Diffstat (limited to 'shared/extra-utils/videos/videos.ts')
-rw-r--r--shared/extra-utils/videos/videos.ts48
1 files changed, 37 insertions, 11 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 99e591cb2..2f7f2182c 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -5,21 +5,23 @@ import { pathExists, readdir, readFile } from 'fs-extra'
5import * as parseTorrent from 'parse-torrent' 5import * as parseTorrent from 'parse-torrent'
6import { extname, join } from 'path' 6import { extname, join } from 'path'
7import * as request from 'supertest' 7import * as request from 'supertest'
8import { v4 as uuidv4 } from 'uuid'
9import validator from 'validator'
10import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
11import { VideoDetails, VideoPrivacy } from '../../models/videos'
8import { 12import {
9 buildAbsoluteFixturePath, 13 buildAbsoluteFixturePath,
10 getMyUserInformation, 14 buildServerDirectory,
15 dateIsValid,
11 immutableAssign, 16 immutableAssign,
12 makeGetRequest,
13 makePutBodyRequest,
14 makeUploadRequest,
15 root, 17 root,
16 ServerInfo, 18 testImage,
17 testImage 19 webtorrentAdd
18} from '../' 20} from '../miscs/miscs'
19import validator from 'validator' 21import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
20import { VideoDetails, VideoPrivacy } from '../../models/videos' 22import { waitJobs } from '../server/jobs'
21import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, loadLanguages, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 23import { ServerInfo } from '../server/servers'
22import { dateIsValid, webtorrentAdd, buildServerDirectory } from '../miscs/miscs' 24import { getMyUserInformation } from '../users/users'
23 25
24loadLanguages() 26loadLanguages()
25 27
@@ -644,11 +646,34 @@ async function getLocalIdByUUID (url: string, uuid: string) {
644 return res.body.id 646 return res.body.id
645} 647}
646 648
649// serverNumber starts from 1
650async function uploadRandomVideoOnServers (servers: ServerInfo[], serverNumber: number, additionalParams: any = {}) {
651 const server = servers.find(s => s.serverNumber === serverNumber)
652 const res = await uploadRandomVideo(server, false, additionalParams)
653
654 await waitJobs(servers)
655
656 return res
657}
658
659async function uploadRandomVideo (server: ServerInfo, wait = true, additionalParams: any = {}) {
660 const prefixName = additionalParams.prefixName || ''
661 const name = prefixName + uuidv4()
662
663 const data = Object.assign({ name }, additionalParams)
664 const res = await uploadVideo(server.url, server.accessToken, data)
665
666 if (wait) await waitJobs([ server ])
667
668 return { uuid: res.body.video.uuid, name }
669}
670
647// --------------------------------------------------------------------------- 671// ---------------------------------------------------------------------------
648 672
649export { 673export {
650 getVideoDescription, 674 getVideoDescription,
651 getVideoCategories, 675 getVideoCategories,
676 uploadRandomVideo,
652 getVideoLicences, 677 getVideoLicences,
653 videoUUIDToId, 678 videoUUIDToId,
654 getVideoPrivacies, 679 getVideoPrivacies,
@@ -666,6 +691,7 @@ export {
666 getVideosListWithToken, 691 getVideosListWithToken,
667 uploadVideo, 692 uploadVideo,
668 getVideosWithFilters, 693 getVideosWithFilters,
694 uploadRandomVideoOnServers,
669 updateVideo, 695 updateVideo,
670 rateVideo, 696 rateVideo,
671 viewVideo, 697 viewVideo,