From 590fb5069038e69898123bb795f789683216d837 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Aug 2018 16:23:45 +0200 Subject: Add tests regarding video import --- server/tests/utils/server/config.ts | 66 +++++++++++++++++++++++++++++- server/tests/utils/videos/video-imports.ts | 37 +++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 server/tests/utils/videos/video-imports.ts (limited to 'server/tests/utils') diff --git a/server/tests/utils/server/config.ts b/server/tests/utils/server/config.ts index 57f95a603..e21614282 100644 --- a/server/tests/utils/server/config.ts +++ b/server/tests/utils/server/config.ts @@ -44,6 +44,69 @@ function updateCustomConfig (url: string, token: string, newCustomConfig: Custom }) } +function updateCustomSubConfig (url: string, token: string, newConfig: any) { + const updateParams: CustomConfig = { + instance: { + name: 'PeerTube updated', + shortDescription: 'my short description', + description: 'my super description', + terms: 'my super terms', + defaultClientRoute: '/videos/recently-added', + defaultNSFWPolicy: 'blur', + customizations: { + javascript: 'alert("coucou")', + css: 'body { background-color: red; }' + } + }, + services: { + twitter: { + username: '@MySuperUsername', + whitelisted: true + } + }, + cache: { + previews: { + size: 2 + }, + captions: { + size: 3 + } + }, + signup: { + enabled: false, + limit: 5 + }, + admin: { + email: 'superadmin1@example.com' + }, + user: { + videoQuota: 5242881 + }, + transcoding: { + enabled: true, + threads: 1, + resolutions: { + '240p': false, + '360p': true, + '480p': true, + '720p': false, + '1080p': false + } + }, + import: { + videos: { + http: { + enabled: false + } + } + } + } + + Object.assign(updateParams, newConfig) + + return updateCustomConfig(url, token, updateParams) +} + function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { const path = '/api/v1/config/custom' @@ -62,5 +125,6 @@ export { getCustomConfig, updateCustomConfig, getAbout, - deleteCustomConfig + deleteCustomConfig, + updateCustomSubConfig } diff --git a/server/tests/utils/videos/video-imports.ts b/server/tests/utils/videos/video-imports.ts new file mode 100644 index 000000000..e0f916990 --- /dev/null +++ b/server/tests/utils/videos/video-imports.ts @@ -0,0 +1,37 @@ +import { VideoImportCreate } from '../../../../shared/models/videos' +import { makeGetRequest, makePostBodyRequest } from '..' + +function getYoutubeVideoUrl () { + return 'https://youtu.be/msX3jv1XdvM' +} + +function importVideo (url: string, token: string, attributes: VideoImportCreate) { + const path = '/api/v1/videos/imports' + + return makePostBodyRequest({ + url, + path, + token, + fields: attributes, + statusCodeExpected: 200 + }) +} + +function getMyVideoImports (url: string, token: string) { + const path = '/api/v1/users/me/videos/imports' + + return makeGetRequest({ + url, + path, + token, + statusCodeExpected: 200 + }) +} + +// --------------------------------------------------------------------------- + +export { + getYoutubeVideoUrl, + importVideo, + getMyVideoImports +} -- cgit v1.2.3