diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-03 16:23:45 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | 590fb5069038e69898123bb795f789683216d837 (patch) | |
tree | ddb3d1830b7d64ebae214dd65a94dd3d16324819 /server/tests/utils | |
parent | 5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e (diff) | |
download | PeerTube-590fb5069038e69898123bb795f789683216d837.tar.gz PeerTube-590fb5069038e69898123bb795f789683216d837.tar.zst PeerTube-590fb5069038e69898123bb795f789683216d837.zip |
Add tests regarding video import
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/server/config.ts | 66 | ||||
-rw-r--r-- | server/tests/utils/videos/video-imports.ts | 37 |
2 files changed, 102 insertions, 1 deletions
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 | |||
44 | }) | 44 | }) |
45 | } | 45 | } |
46 | 46 | ||
47 | function updateCustomSubConfig (url: string, token: string, newConfig: any) { | ||
48 | const updateParams: CustomConfig = { | ||
49 | instance: { | ||
50 | name: 'PeerTube updated', | ||
51 | shortDescription: 'my short description', | ||
52 | description: 'my super description', | ||
53 | terms: 'my super terms', | ||
54 | defaultClientRoute: '/videos/recently-added', | ||
55 | defaultNSFWPolicy: 'blur', | ||
56 | customizations: { | ||
57 | javascript: 'alert("coucou")', | ||
58 | css: 'body { background-color: red; }' | ||
59 | } | ||
60 | }, | ||
61 | services: { | ||
62 | twitter: { | ||
63 | username: '@MySuperUsername', | ||
64 | whitelisted: true | ||
65 | } | ||
66 | }, | ||
67 | cache: { | ||
68 | previews: { | ||
69 | size: 2 | ||
70 | }, | ||
71 | captions: { | ||
72 | size: 3 | ||
73 | } | ||
74 | }, | ||
75 | signup: { | ||
76 | enabled: false, | ||
77 | limit: 5 | ||
78 | }, | ||
79 | admin: { | ||
80 | email: 'superadmin1@example.com' | ||
81 | }, | ||
82 | user: { | ||
83 | videoQuota: 5242881 | ||
84 | }, | ||
85 | transcoding: { | ||
86 | enabled: true, | ||
87 | threads: 1, | ||
88 | resolutions: { | ||
89 | '240p': false, | ||
90 | '360p': true, | ||
91 | '480p': true, | ||
92 | '720p': false, | ||
93 | '1080p': false | ||
94 | } | ||
95 | }, | ||
96 | import: { | ||
97 | videos: { | ||
98 | http: { | ||
99 | enabled: false | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | Object.assign(updateParams, newConfig) | ||
106 | |||
107 | return updateCustomConfig(url, token, updateParams) | ||
108 | } | ||
109 | |||
47 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { | 110 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
48 | const path = '/api/v1/config/custom' | 111 | const path = '/api/v1/config/custom' |
49 | 112 | ||
@@ -62,5 +125,6 @@ export { | |||
62 | getCustomConfig, | 125 | getCustomConfig, |
63 | updateCustomConfig, | 126 | updateCustomConfig, |
64 | getAbout, | 127 | getAbout, |
65 | deleteCustomConfig | 128 | deleteCustomConfig, |
129 | updateCustomSubConfig | ||
66 | } | 130 | } |
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 @@ | |||
1 | import { VideoImportCreate } from '../../../../shared/models/videos' | ||
2 | import { makeGetRequest, makePostBodyRequest } from '..' | ||
3 | |||
4 | function getYoutubeVideoUrl () { | ||
5 | return 'https://youtu.be/msX3jv1XdvM' | ||
6 | } | ||
7 | |||
8 | function importVideo (url: string, token: string, attributes: VideoImportCreate) { | ||
9 | const path = '/api/v1/videos/imports' | ||
10 | |||
11 | return makePostBodyRequest({ | ||
12 | url, | ||
13 | path, | ||
14 | token, | ||
15 | fields: attributes, | ||
16 | statusCodeExpected: 200 | ||
17 | }) | ||
18 | } | ||
19 | |||
20 | function getMyVideoImports (url: string, token: string) { | ||
21 | const path = '/api/v1/users/me/videos/imports' | ||
22 | |||
23 | return makeGetRequest({ | ||
24 | url, | ||
25 | path, | ||
26 | token, | ||
27 | statusCodeExpected: 200 | ||
28 | }) | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------------------- | ||
32 | |||
33 | export { | ||
34 | getYoutubeVideoUrl, | ||
35 | importVideo, | ||
36 | getMyVideoImports | ||
37 | } | ||