From c4d525ae60408a2a337fd6e476a9b30324522cf1 Mon Sep 17 00:00:00 2001 From: forest93 Date: Thu, 10 Oct 2024 23:47:04 +0800 Subject: [PATCH] #116 Use dman2 wiki for FANDOM CI automation tests. --- UnitTestProject1/Endpoints.cs | 5 ++--- UnitTestProject1/Tests/RevisionGeneratorTests.cs | 6 +++++- UnitTestProject1/Tests/SiteTests.cs | 6 +++--- UnitTestProject1/Tests/WikiaApiTests.cs | 6 +++--- WikiClientLibrary/Generators/RevisionsGenerator.cs | 8 ++++---- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/UnitTestProject1/Endpoints.cs b/UnitTestProject1/Endpoints.cs index 12f15a74d..b32594afd 100644 --- a/UnitTestProject1/Endpoints.cs +++ b/UnitTestProject1/Endpoints.cs @@ -33,9 +33,8 @@ public static class Endpoints public const string WikidataBeta = "https://wikidata.beta.wmflabs.org/w/api.php"; - // Suggested by KockaAdmiralac. - // It's on MW 1.33 now. Well. - public const string WikiaTest = "https://dman.fandom.com/api.php"; + // It's on MW 1.39 now. Well. + public const string WikiaTest = "https://dman2.fandom.com/api.php"; // It's on MW 1.19 as of now. public const string TFWiki = "https://tfwiki.net/api.php"; diff --git a/UnitTestProject1/Tests/RevisionGeneratorTests.cs b/UnitTestProject1/Tests/RevisionGeneratorTests.cs index 54fa2577d..d9ddde848 100644 --- a/UnitTestProject1/Tests/RevisionGeneratorTests.cs +++ b/UnitTestProject1/Tests/RevisionGeneratorTests.cs @@ -66,7 +66,11 @@ public async Task WpTestEnumRevisionsTest3() public async Task WikiaEnumRevisionsTest1() { var site = await WikiaTestSiteAsync; - var page = new WikiPage(site, "Dman Wikia"); + var page = new WikiPage(site, "DMan \u2161 Wiki"); + await page.RefreshAsync(); + // Sanity check: the page exists. + Assert.True(page.Exists); + var gen = page.CreateRevisionsGenerator(); gen.PaginationSize = 20; var revisions = await gen.EnumItemsAsync().Skip(5).Take(5).ToListAsync(); diff --git a/UnitTestProject1/Tests/SiteTests.cs b/UnitTestProject1/Tests/SiteTests.cs index ddc40d12e..5e33062a5 100644 --- a/UnitTestProject1/Tests/SiteTests.cs +++ b/UnitTestProject1/Tests/SiteTests.cs @@ -100,7 +100,7 @@ public async Task TestWikia() { var site = await WikiaTestSiteAsync; ShallowTrace(site); - Assert.Equal("Discussion Manual Wiki", site.SiteInfo.SiteName); + Assert.Equal("DMan Ⅱ Wiki", site.SiteInfo.SiteName); ValidateNamespaces(site); } @@ -214,12 +214,12 @@ public async Task WpTest2OpenSearchTest() public async Task WikiaOpenSearchTest() { var site = await WikiaTestSiteAsync; - var result = await Task.WhenAll(site.OpenSearchAsync("Dman Wi"), + var result = await Task.WhenAll(site.OpenSearchAsync("Dman Ⅱ W"), site.OpenSearchAsync("THISTITLEDOESNOTEXIST")); ShallowTrace(result[0]); ShallowTrace(result[1]); Assert.True(result[0].Count > 0); - Assert.Contains(result[0], e => e.Title == "Dman Wikia"); + Assert.Contains(result[0], e => e.Title == "DMan \u2161 Wiki"); Assert.True(result[1].Count == 0); } diff --git a/UnitTestProject1/Tests/WikiaApiTests.cs b/UnitTestProject1/Tests/WikiaApiTests.cs index 9b401e630..cbc94ebc0 100644 --- a/UnitTestProject1/Tests/WikiaApiTests.cs +++ b/UnitTestProject1/Tests/WikiaApiTests.cs @@ -28,16 +28,16 @@ public async Task FetchUsersTest() Assert.Equal(2, users.Length); Assert.Equal("Jasonr", users[0].Name); Assert.Equal("Jasonr", users[0].Title); - Assert.Equal("https://dman.fandom.com/wiki/User:Jasonr", users[0].UserPageUrl); + Assert.Equal(Uri.UnescapeDataString(site.SiteInfo.MakeArticleUrl("User:Jasonr")), users[0].UserPageUrl); Assert.Equal(1, users[0].Id); Assert.Equal("Angela", users[1].Name); Assert.Equal("Angela", users[1].Title); - Assert.Equal("https://dman.fandom.com/wiki/User:Angela", users[1].UserPageUrl); + Assert.Equal(Uri.UnescapeDataString(site.SiteInfo.MakeArticleUrl("User:Angela")), users[1].UserPageUrl); Assert.Equal(2, users[1].Id); var user = await site.FetchUserAsync("__mattisManzel_"); Assert.Equal("MattisManzel", user.Name); Assert.Equal("MattisManzel", user.Title); - Assert.Equal("https://dman.fandom.com/wiki/User:MattisManzel", user.UserPageUrl); + Assert.Equal(Uri.UnescapeDataString(site.SiteInfo.MakeArticleUrl("User:MattisManzel")), user.UserPageUrl); Assert.Equal(4, user.Id); user = await site.FetchUserAsync("user_not_exist"); Assert.Null(user); diff --git a/WikiClientLibrary/Generators/RevisionsGenerator.cs b/WikiClientLibrary/Generators/RevisionsGenerator.cs index 574a78df8..1f7cebdd2 100644 --- a/WikiClientLibrary/Generators/RevisionsGenerator.cs +++ b/WikiClientLibrary/Generators/RevisionsGenerator.cs @@ -62,7 +62,7 @@ protected override Revision ItemFromJson(JsonNode json, JsonObject jpage) } /// - /// Whether to list revisions in an ascending order of time. + /// Whether to list revisions in ascending order of time. /// /// true, if oldest revisions are listed first; or false, if newest revisions are listed first. /// @@ -115,7 +115,7 @@ public RevisionsPropertyProvider PropertyProvider /// Asynchronously enumerates the pages from generator. /// /// Using revisions as generator is not supported until MediaWiki 1.25. - /// Usually this generator will only returns the title specified in + /// Usually this generator will only return the title specified in /// or . /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -129,7 +129,7 @@ public override IAsyncEnumerable EnumPagesAsync() /// Asynchronously enumerates the pages from generator. /// /// Using revisions as generator is not supported until MediaWiki 1.25. - /// Usually this generator will only returns the title specified in + /// Usually this generator will only return the title specified in /// or . /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -143,7 +143,7 @@ public override IAsyncEnumerable EnumPagesAsync(PageQueryOptions optio /// Asynchronously enumerates the pages from generator. /// /// Using revisions as generator is not supported until MediaWiki 1.25. - /// Usually this generator will only returns the title specified in + /// Usually this generator will only return the title specified in /// or . /// [EditorBrowsable(EditorBrowsableState.Never)]