1
0
Fork 0

Improve a little bit completeVideoCheck

This commit is contained in:
Chocobozzz 2024-02-14 15:10:29 +01:00 committed by Chocobozzz
parent f7e4f62870
commit 00ee54329a
6 changed files with 106 additions and 112 deletions

View file

@ -451,7 +451,6 @@ describe('Test follows', function () {
expect(video4).to.not.be.undefined
expect(video6).to.not.be.undefined
const isLocal = false
const checkAttributes = {
name: 'server3-4',
category: 2,
@ -464,7 +463,6 @@ describe('Test follows', function () {
name: 'root',
host: servers[2].host
},
isLocal,
commentsEnabled: true,
downloadEnabled: true,
duration: 5,
@ -475,8 +473,7 @@ describe('Test follows', function () {
channel: {
displayName: 'Main root channel',
name: 'root_channel',
description: '',
isLocal
description: ''
},
fixture: 'video_short.webm',
files: [

View file

@ -44,8 +44,37 @@ describe('Test handle downs', function () {
const unlistedVideoAttributes = { ...videoAttributes, privacy: VideoPrivacy.UNLISTED }
let checkAttributes: any
let unlistedCheckAttributes: any
const checkAttributes = {
name: 'my super name for server 1',
category: 5,
licence: 4,
language: 'ja',
nsfw: true,
description: 'my super description for server 1',
support: 'my super support text for server 1',
account: {
name: 'root',
host: ''
},
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
privacy: VideoPrivacy.PUBLIC,
commentsEnabled: true,
downloadEnabled: true,
channel: {
name: 'root_channel',
displayName: 'Main root channel',
description: ''
},
fixture: 'video_short1.webm',
files: [
{
resolution: 720,
size: 572456
}
]
}
const unlistedCheckAttributes = { ...checkAttributes, privacy: VideoPrivacy.UNLISTED }
let commentCommands: CommentsCommand[]
@ -55,39 +84,8 @@ describe('Test handle downs', function () {
servers = await createMultipleServers(3)
commentCommands = servers.map(s => s.comments)
checkAttributes = {
name: 'my super name for server 1',
category: 5,
licence: 4,
language: 'ja',
nsfw: true,
description: 'my super description for server 1',
support: 'my super support text for server 1',
account: {
name: 'root',
host: servers[0].host
},
isLocal: false,
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
privacy: VideoPrivacy.PUBLIC,
commentsEnabled: true,
downloadEnabled: true,
channel: {
name: 'root_channel',
displayName: 'Main root channel',
description: '',
isLocal: false
},
fixture: 'video_short1.webm',
files: [
{
resolution: 720,
size: 572456
}
]
}
unlistedCheckAttributes = { ...checkAttributes, privacy: VideoPrivacy.UNLISTED }
checkAttributes.account.host = servers[0].host
unlistedCheckAttributes.account.host = servers[0].host
// Get the access tokens
await setAccessTokensToServers(servers)

View file

@ -388,15 +388,13 @@ function runTest (withObjectStorage: boolean) {
name: 'noah_remote',
host: remoteServer.host
},
isLocal: checkServer === remoteServer,
likes: 0,
dislikes: 0,
duration: 5,
channel: {
displayName: 'noah display name',
name: 'noah_second_channel',
description: 'noah description',
isLocal: checkServer === remoteServer
description: 'noah description'
},
fixture: 'video_short.webm',
files: [

View file

@ -90,7 +90,6 @@ describe('Test multiple servers', function () {
// All servers should have this video
let publishedAt: string = null
for (const server of servers) {
const isLocal = server.port === servers[0].port
const checkAttributes = {
name: 'my super name for server 1',
category: 5,
@ -104,7 +103,6 @@ describe('Test multiple servers', function () {
name: 'root',
host: servers[0].host
},
isLocal,
publishedAt,
duration: 10,
tags: [ 'tag1p1', 'tag2p1' ],
@ -114,8 +112,7 @@ describe('Test multiple servers', function () {
channel: {
displayName: 'my channel',
name: 'super_channel_name',
description: 'super channel',
isLocal
description: 'super channel'
},
fixture: 'video_short1.webm',
files: [
@ -182,7 +179,6 @@ describe('Test multiple servers', function () {
// All servers should have this video
for (const server of servers) {
const isLocal = server.url === servers[1].url
const checkAttributes = {
name: 'my super name for server 2',
category: 4,
@ -195,7 +191,6 @@ describe('Test multiple servers', function () {
name: 'user1',
host: servers[1].host
},
isLocal,
commentsEnabled: true,
downloadEnabled: true,
duration: 5,
@ -204,8 +199,7 @@ describe('Test multiple servers', function () {
channel: {
displayName: 'Main user1 channel',
name: 'user1_channel',
description: 'super channel',
isLocal
description: 'super channel'
},
fixture: 'video_short2.webm',
files: [
@ -276,7 +270,6 @@ describe('Test multiple servers', function () {
// All servers should have this video
for (const server of servers) {
const isLocal = server.url === servers[2].url
const { data } = await server.videos.list()
expect(data).to.be.an('array')
@ -305,7 +298,6 @@ describe('Test multiple servers', function () {
name: 'root',
host: servers[2].host
},
isLocal,
duration: 5,
commentsEnabled: true,
downloadEnabled: true,
@ -314,8 +306,7 @@ describe('Test multiple servers', function () {
channel: {
displayName: 'Main root channel',
name: 'root_channel',
description: '',
isLocal
description: ''
},
fixture: 'video_short3.webm',
files: [
@ -341,15 +332,13 @@ describe('Test multiple servers', function () {
},
commentsEnabled: true,
downloadEnabled: true,
isLocal,
duration: 5,
tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
privacy: VideoPrivacy.PUBLIC,
channel: {
displayName: 'Main root channel',
name: 'root_channel',
description: '',
isLocal
description: ''
},
fixture: 'video_short.webm',
files: [
@ -638,7 +627,6 @@ describe('Test multiple servers', function () {
expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
const isLocal = server.url === servers[2].url
const checkAttributes = {
name: 'my super video updated',
category: 10,
@ -652,7 +640,6 @@ describe('Test multiple servers', function () {
name: 'root',
host: servers[2].host
},
isLocal,
duration: 5,
commentsEnabled: true,
downloadEnabled: true,
@ -661,8 +648,7 @@ describe('Test multiple servers', function () {
channel: {
displayName: 'Main root channel',
name: 'root_channel',
description: '',
isLocal
description: ''
},
fixture: 'video_short3.webm',
files: [

View file

@ -36,7 +36,6 @@ describe('Test a single server', function () {
name: 'root',
host: server.host
},
isLocal: true,
duration: 5,
tags: [ 'tag1', 'tag2', 'tag3' ],
privacy: VideoPrivacy.PUBLIC,
@ -45,8 +44,7 @@ describe('Test a single server', function () {
channel: {
displayName: 'Main root channel',
name: 'root_channel',
description: '',
isLocal: true
description: ''
},
fixture: 'video_short.webm',
files: [
@ -69,7 +67,6 @@ describe('Test a single server', function () {
name: 'root',
host: server.host
},
isLocal: true,
tags: [ 'tagup1', 'tagup2' ],
privacy: VideoPrivacy.PUBLIC,
duration: 5,
@ -78,8 +75,7 @@ describe('Test a single server', function () {
channel: {
name: 'root_channel',
displayName: 'Main root channel',
description: '',
isLocal: true
description: ''
},
fixture: 'video_short3.webm',
files: [

View file

@ -4,7 +4,7 @@ import { expect } from 'chai'
import { pathExists } from 'fs-extra/esm'
import { readdir } from 'fs/promises'
import { basename, join } from 'path'
import { pick, uuidRegex } from '@peertube/peertube-core-utils'
import { uuidRegex } from '@peertube/peertube-core-utils'
import { HttpStatusCode, HttpStatusCodeType, VideoCaption, VideoDetails, VideoPrivacy, VideoResolution } from '@peertube/peertube-models'
import {
loadLanguages,
@ -17,8 +17,9 @@ import { getLowercaseExtension } from '@peertube/peertube-node-utils'
import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs } from '@peertube/peertube-server-commands'
import { dateIsValid, expectStartWith, testImageGeneratedByFFmpeg } from './checks.js'
import { checkWebTorrentWorks } from './webtorrent.js'
import { completeCheckHlsPlaylist } from './streaming-playlists.js'
async function completeWebVideoFilesCheck (options: {
export async function completeWebVideoFilesCheck (options: {
server: PeerTubeServer
originServer: PeerTubeServer
videoUUID: string
@ -109,10 +110,12 @@ async function completeWebVideoFilesCheck (options: {
}
}
async function completeVideoCheck (options: {
export async function completeVideoCheck (options: {
server: PeerTubeServer
originServer: PeerTubeServer
videoUUID: string
objectStorageBaseUrl?: string
attributes: {
@ -124,32 +127,41 @@ async function completeVideoCheck (options: {
commentsEnabled: boolean
downloadEnabled: boolean
description: string
publishedAt?: string
support: string
duration: number
tags: string[]
privacy: number
publishedAt?: string
originallyPublishedAt?: string
account: {
name: string
host: string
}
isLocal: boolean
tags: string[]
privacy: number
likes?: number
dislikes?: number
duration: number
channel: {
displayName: string
name: string
description: string
isLocal: boolean
}
fixture: string
files: {
thumbnailfile?: string
previewfile?: string
files?: {
resolution: number
size: number
}[]
thumbnailfile?: string
previewfile?: string
hls?: {
hlsOnly: boolean
resolutions: number[]
}
}
}) {
const { attributes, originServer, server, videoUUID, objectStorageBaseUrl } = options
@ -164,24 +176,30 @@ async function completeVideoCheck (options: {
expect(video.name).to.equal(attributes.name)
expect(video.category.id).to.equal(attributes.category)
expect(video.category.label).to.equal(attributes.category !== null ? VIDEO_CATEGORIES[attributes.category] : 'Unknown')
expect(video.licence.id).to.equal(attributes.licence)
expect(video.licence.label).to.equal(attributes.licence !== null ? VIDEO_LICENCES[attributes.licence] : 'Unknown')
expect(video.language.id).to.equal(attributes.language)
expect(video.language.label).to.equal(attributes.language !== null ? VIDEO_LANGUAGES[attributes.language] : 'Unknown')
expect(video.privacy.id).to.deep.equal(attributes.privacy)
expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
expect(video.nsfw).to.equal(attributes.nsfw)
expect(video.description).to.equal(attributes.description)
expect(video.account.id).to.be.a('number')
expect(video.account.host).to.equal(attributes.account.host)
expect(video.account.name).to.equal(attributes.account.name)
expect(video.channel.displayName).to.equal(attributes.channel.displayName)
expect(video.channel.name).to.equal(attributes.channel.name)
expect(video.likes).to.equal(attributes.likes)
expect(video.dislikes).to.equal(attributes.dislikes)
expect(video.isLocal).to.equal(attributes.isLocal)
expect(video.isLocal).to.equal(server.url === originServer.url)
expect(video.duration).to.equal(attributes.duration)
expect(video.url).to.contain(originServer.host)
expect(video.tags).to.deep.equal(attributes.tags)
expect(video.commentsEnabled).to.equal(attributes.commentsEnabled)
expect(video.downloadEnabled).to.equal(attributes.downloadEnabled)
expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.publishedAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true
@ -196,18 +214,16 @@ async function completeVideoCheck (options: {
expect(video.originallyPublishedAt).to.be.null
}
expect(video.files).to.have.lengthOf(attributes.files.length)
expect(video.tags).to.deep.equal(attributes.tags)
expect(video.account.id).to.be.a('number')
expect(video.account.name).to.equal(attributes.account.name)
expect(video.account.host).to.equal(attributes.account.host)
expect(video.channel.displayName).to.equal(attributes.channel.displayName)
expect(video.channel.name).to.equal(attributes.channel.name)
expect(video.channel.host).to.equal(attributes.account.host)
expect(video.channel.isLocal).to.equal(attributes.channel.isLocal)
expect(video.channel.isLocal).to.equal(server.url === originServer.url)
expect(video.channel.createdAt).to.exist
expect(dateIsValid(video.channel.updatedAt.toString())).to.be.true
expect(video.commentsEnabled).to.equal(attributes.commentsEnabled)
expect(video.downloadEnabled).to.equal(attributes.downloadEnabled)
expect(video.thumbnailPath).to.exist
await testImageGeneratedByFFmpeg(server.url, attributes.thumbnailfile || attributes.fixture, video.thumbnailPath)
@ -217,16 +233,30 @@ async function completeVideoCheck (options: {
await testImageGeneratedByFFmpeg(server.url, attributes.previewfile, video.previewPath)
}
await completeWebVideoFilesCheck({
server,
originServer,
videoUUID: video.uuid,
objectStorageBaseUrl,
...pick(attributes, [ 'fixture', 'files' ])
})
if (attributes.files) {
await completeWebVideoFilesCheck({
server,
originServer,
videoUUID: video.uuid,
objectStorageBaseUrl,
files: attributes.files,
fixture: attributes.fixture
})
}
if (attributes.hls) {
await completeCheckHlsPlaylist({
objectStorageBaseUrl,
servers: [ server ],
videoUUID: video.uuid,
hlsOnly: attributes.hls.hlsOnly,
resolutions: attributes.hls.resolutions
})
}
}
async function checkVideoFilesWereRemoved (options: {
export async function checkVideoFilesWereRemoved (options: {
server: PeerTubeServer
video: VideoDetails
captions?: VideoCaption[]
@ -280,13 +310,13 @@ async function checkVideoFilesWereRemoved (options: {
}
}
async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {
export async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {
for (const server of servers) {
server.store.videoDetails = await server.videos.get({ id: uuid })
}
}
function checkUploadVideoParam (options: {
export function checkUploadVideoParam (options: {
server: PeerTubeServer
token: string
attributes: Partial<VideoEdit>
@ -310,7 +340,7 @@ function checkUploadVideoParam (options: {
}
// serverNumber starts from 1
async function uploadRandomVideoOnServers (
export async function uploadRandomVideoOnServers (
servers: PeerTubeServer[],
serverNumber: number,
additionalParams?: VideoEdit & { prefixName?: string }
@ -322,14 +352,3 @@ async function uploadRandomVideoOnServers (
return res
}
// ---------------------------------------------------------------------------
export {
completeVideoCheck,
completeWebVideoFilesCheck,
checkUploadVideoParam,
uploadRandomVideoOnServers,
checkVideoFilesWereRemoved,
saveVideoInServers
}