Skip to content

Commit

Permalink
Add test to check if more than 20 tags is visible in sankaku
Browse files Browse the repository at this point in the history
  • Loading branch information
ImoutoChan committed Oct 3, 2023
1 parent 81f9b58 commit 175ba1d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ImoutoRebirth.Arachne.Infrastructure.LoaderFabrics;
using ImoutoRebirth.Arachne.Infrastructure.Models.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Polly;
using Polly.Extensions.Http;

Expand Down Expand Up @@ -40,6 +41,21 @@ var policy

services.AddTransient<DanbooruSettings>(x => danbooruSettings);
services.AddTransient<SankakuSettings>(x => sankakuSettings);
services.AddTransient<IOptions<Imouto.BooruParser.Implementations.Sankaku.SankakuSettings>>(_ =>
Options.Create(new Imouto.BooruParser.Implementations.Sankaku.SankakuSettings
{
Login = sankakuSettings.Login,
Password = sankakuSettings.Password,
PauseBetweenRequestsInMs = sankakuSettings.Delay
}));
services.AddTransient<IOptions<Imouto.BooruParser.Implementations.Danbooru.DanbooruSettings>>(_ =>
Options.Create(new Imouto.BooruParser.Implementations.Danbooru.DanbooruSettings
{
Login = danbooruSettings.Login,
ApiKey = danbooruSettings.ApiKey,
PauseBetweenRequestsInMs = danbooruSettings.Delay,
BotUserAgent = danbooruSettings.BotUserAgent
}));

services.AddTransient<IBooruPostConverter, BooruPostConverter>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
using FluentAssertions;
using Flurl.Http.Configuration;
using Imouto.BooruParser.Implementations.Sankaku;
using ImoutoRebirth.Arachne.Infrastructure.LoaderFabrics;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Xunit;
using SankakuSettings = ImoutoRebirth.Arachne.Infrastructure.Models.Settings.SankakuSettings;

namespace ImoutoRebirth.Arachne.Tests.Infrastructure;

public class YandereLoaderTests
{
[Fact]
public async Task ShouldHaveAllTags()
{
// arrange
var settings = new SankakuSettings
{
Login = "testuser159",
Password = "testuser159",
Delay = 6000
};

var fabric = new SankakuLoaderFabric(settings,
new SankakuAuthManager(new MemoryCache(new MemoryCacheOptions()), Options.Create(
new Imouto.BooruParser.Implementations.Sankaku.SankakuSettings()
{
Login = settings.Login,
Password = settings.Password,
PauseBetweenRequestsInMs = settings.Delay
}),
new PerBaseUrlFlurlClientFactory()), new PerBaseUrlFlurlClientFactory());
var loader = fabric.Create();

// act
var post = await loader.GetPostByMd5Async("4c58f8a682ccdf6eef5b3ed28678c71d");

// assert
post!.Tags.Should().Contain(x => x.Name == "tattoo");
}

[Fact]
public async Task ShouldHaveMd5OnChildren()
{
Expand Down

0 comments on commit 175ba1d

Please sign in to comment.