E4: prove dei video fermi e dimostrazione a ogni ora
Completa l'elenco di prove del progetto: analizzatore (grana, luce che pulsa, foto notturna, contenitori, durata sconosciuta, flussi rovinati), servizio (lavori lunghi, file spariti o cambiati, errori, «Interrompi», chiusura), copie del fotogramma (pausa e ripresa, validazione, video sempre intero), API (selezioni, stesso file, eventi) e l'interfaccia vera nel browser: visualizzatore, «Salva il fotogramma», «Cerca i video fermi», Dashboard e filtro «Video fermi». Le prove hanno trovato che la dimostrazione dipendeva dall'ora: la storia ferma poteva avere la copertina del video fermo di marta (un file solo invece di due) e il video «Non analizzabile» poteva mancare. Ora la storia è su un'altra immagine e, se le immagini senza copie non bastano, si usano quelle di foto copiate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eea4394a0f
commit
066addbc84
10 files changed
+1100
-18
No files matched your search
@@ -10,6 +10,7 @@ using Febe.Core.Library.StillVideos;
|
||||
using Febe.Tests.Support;
|
||||
using Febe.Tests.Web.Support;
|
||||
using Febe.Web.Demo;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Febe.Tests.Web;
|
||||
|
||||
@@ -202,6 +203,57 @@ public sealed class DemoStillVideoTests
|
||||
Assert.HasCount(2, (await OkAsync(HttpMethod.Get, "/api/library?kind=stillvideos&limit=100")).Items("tiles").ToList(), "the moving file is never still");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(9)]
|
||||
[DataRow(20)]
|
||||
[Timeout(600_000, CooperativeCancellation = true)]
|
||||
public async Task WhateverTheHourTheDemoHasItsStillVideos(int hour)
|
||||
{
|
||||
// The demo is built around its local time (posts of «oggi» are there or not yet): the still videos never depend
|
||||
// on it. The hour is the zone's, so the test asks for the same thing whenever it runs.
|
||||
var ct = TestContext.CancellationToken;
|
||||
using var temp = new TempFolder("demo-fermi-ore");
|
||||
var offset = TimeSpan.FromMinutes(Math.Round(((hour + 0.5) * 60) - DateTimeOffset.UtcNow.TimeOfDay.TotalMinutes));
|
||||
offset = offset > TimeSpan.FromHours(12) ? offset - TimeSpan.FromHours(24) : offset < TimeSpan.FromHours(-12) ? offset + TimeSpan.FromHours(24) : offset;
|
||||
var zone = TimeZoneInfo.CreateCustomTimeZone("prova", offset, "prova", "prova");
|
||||
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, zone, temp.Path), ct);
|
||||
|
||||
Assert.HasCount(2, demo.World.StillVideoFiles);
|
||||
var tiles = (await demo.Storage.Entries.QueryLibraryAsync(
|
||||
new Febe.Core.Storage.LibraryQuery { Filter = new Febe.Core.Storage.LibraryFilter { Kind = Febe.Core.Storage.LibraryKindFilter.StillVideos }, Limit = 100 },
|
||||
ct)).Tiles;
|
||||
Assert.HasCount(2, tiles, "one post and one story");
|
||||
var accounts = await demo.Storage.Accounts.ListAsync(ct);
|
||||
var marta = accounts.Single(a => a.Username == DemoStillVideos.StillAccount).Id;
|
||||
Assert.AreEqual(1, tiles.Count(t => t.AccountId == marta));
|
||||
var entries = await Task.WhenAll(tiles.Select(async t => (await demo.Storage.Entries.GetAsync(t.EntryId, ct))!));
|
||||
Assert.AreEqual(1, entries.Count(e => e.Kind == EntryKind.Story && e.AccountId != marta));
|
||||
Assert.IsTrue(entries.All(e => e.PublishedAt <= demo.App.Services.GetRequiredService<Febe.Core.Abstractions.IClock>().Now), "published, not to come");
|
||||
|
||||
var outcomes = new List<(VideoAnalysisOutcome, string?)>();
|
||||
var unanalysed = 0;
|
||||
foreach (var video in await VideosAsync(demo, marta, ct))
|
||||
{
|
||||
if (await demo.Storage.VideoAnalyses.GetAsync(video.Sha256!, ct) is { } analysis)
|
||||
{
|
||||
outcomes.Add((analysis.Outcome, analysis.Note));
|
||||
}
|
||||
else
|
||||
{
|
||||
unanalysed++;
|
||||
}
|
||||
}
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
new (VideoAnalysisOutcome, string?)[]
|
||||
{
|
||||
(VideoAnalysisOutcome.Still, null), (VideoAnalysisOutcome.Moving, null), (VideoAnalysisOutcome.NotAnalyzable, VideoAnalysisNotes.TooSlow),
|
||||
},
|
||||
outcomes.Distinct().ToArray(),
|
||||
string.Join(", ", outcomes));
|
||||
Assert.IsGreaterThan(0, unanalysed, "«È un video fermo?» has a video to be tried on");
|
||||
}
|
||||
|
||||
private static async Task<Media> UnanalysedVideoAsync(DemoHost demo, long accountId, CancellationToken ct)
|
||||
{
|
||||
foreach (var media in await VideosAsync(demo, accountId, ct))
|
||||
@@ -218,17 +270,26 @@ public sealed class DemoStillVideoTests
|
||||
/// <summary>The present videos of an account in the library, newest first.</summary>
|
||||
private static async Task<List<Media>> VideosAsync(DemoHost demo, long accountId, CancellationToken ct)
|
||||
{
|
||||
var page = await demo.Storage.Entries.QueryLibraryAsync(
|
||||
new Febe.Core.Storage.LibraryQuery { Filter = new Febe.Core.Storage.LibraryFilter { AccountIds = [accountId] }, Mode = Febe.Core.Storage.MosaicMode.Files, Limit = 1000 },
|
||||
ct);
|
||||
// Every page: @marta.demo has more than a thousand files, and the videos the demo analysed can be among the oldest
|
||||
// (the pictures that no copy uses depend on the hour).
|
||||
var videos = new List<Media>();
|
||||
foreach (var tile in page.Tiles.Where(t => t.CoverKind == MediaKind.Video))
|
||||
Febe.Core.Storage.LibraryCursor? cursor = null;
|
||||
do
|
||||
{
|
||||
if (await demo.Storage.Media.GetAsync(tile.CoverMediaId!.Value, ct) is { Sha256: not null } media && EntryStateRules.IsPresent(media.State))
|
||||
var page = await demo.Storage.Entries.QueryLibraryAsync(
|
||||
new Febe.Core.Storage.LibraryQuery { Filter = new Febe.Core.Storage.LibraryFilter { AccountIds = [accountId] }, Mode = Febe.Core.Storage.MosaicMode.Files, Cursor = cursor, Limit = 500 },
|
||||
ct);
|
||||
foreach (var tile in page.Tiles.Where(t => t.CoverKind == MediaKind.Video))
|
||||
{
|
||||
videos.Add(media);
|
||||
if (await demo.Storage.Media.GetAsync(tile.CoverMediaId!.Value, ct) is { Sha256: not null } media && EntryStateRules.IsPresent(media.State))
|
||||
{
|
||||
videos.Add(media);
|
||||
}
|
||||
}
|
||||
|
||||
cursor = page.Older;
|
||||
}
|
||||
while (cursor is not null);
|
||||
|
||||
return videos;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user