From 12a27c738d5ec3c7184175a71fa80d8976fcc190 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 20 Jun 2024 09:37:46 -0500 Subject: [PATCH 1/2] CLDR-16835 fix phase check for adding items - adding items was using the overall phase instead of the specific phase --- .../src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java index efa531d45e3..2eaf67925ec 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java @@ -486,8 +486,7 @@ public static VoteResponse getHandleVoteResponse( CandidateInfo ci = calculateCandidateItem(result, val, dataRow); // Now, recalculate the statusAction for accepting the new item r.statusAction = - CLDRConfig.getInstance() - .getPhase() + SurveyMain.checkCLDRPhase(locale) .getAcceptNewItemAction( ci, dataRow, From 1e3d535db48044d6ae5ce897da25eb2415586f9c Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 20 Jun 2024 11:08:02 -0500 Subject: [PATCH 2/2] CLDR-16835 fix phase check for unit tests - the phase system needs to return BUILD when in unit tests. --- .../main/java/org/unicode/cldr/web/SurveyMain.java | 3 +++ .../unicode/cldr/web/DataDrivenSTTestHandler.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java index 08c09c31f02..40c5f384138 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java @@ -3613,6 +3613,9 @@ public static Phase surveyPhase(CLDRLocale locale) { * @returns the current CheckCLDR phase for the locale. This is the preferred API. */ public static CheckCLDR.Phase checkCLDRPhase(CLDRLocale loc) { + if (CLDRConfig.getInstance().getEnvironment() == CLDRConfig.Environment.UNITTEST) { + return CheckCLDR.Phase.BUILD; + } return surveyPhase(loc).toCheckCLDRPhase(); } diff --git a/tools/cldr-apps/src/test/java/org/unicode/cldr/web/DataDrivenSTTestHandler.java b/tools/cldr-apps/src/test/java/org/unicode/cldr/web/DataDrivenSTTestHandler.java index aa71192060c..6fd9cd5e3c9 100644 --- a/tools/cldr-apps/src/test/java/org/unicode/cldr/web/DataDrivenSTTestHandler.java +++ b/tools/cldr-apps/src/test/java/org/unicode/cldr/web/DataDrivenSTTestHandler.java @@ -11,6 +11,8 @@ import java.util.Map; import java.util.TreeMap; import org.unicode.cldr.draft.FileUtilities; +import org.unicode.cldr.test.CheckCLDR; +import org.unicode.cldr.util.CLDRConfig; import org.unicode.cldr.util.CLDRFile; import org.unicode.cldr.util.CLDRFile.DraftStatus; import org.unicode.cldr.util.CLDRLocale; @@ -462,6 +464,14 @@ private void handleElementApivote( if (elem.equals("apiunvote")) { value = null; } + assertEquals( + CheckCLDR.Phase.BUILD, + SurveyMain.checkCLDRPhase(locale), + () -> "CheckCLDR Phase for " + locale); + assertEquals( + CheckCLDR.Phase.BUILD, + CLDRConfig.getInstance().getPhase(), + "CLDRConfig.getInstance().getPhase()"); final CookieSession mySession = CookieSession.getTestSession(u); try { final VoteAPI.VoteResponse r = @@ -485,7 +495,8 @@ private void handleElementApivote( System.out.println("Caught expected: " + iae); } else { iae.printStackTrace(); - fail("Unexpected exception: " + iae); + fail("Phase: " + SurveyMain.checkCLDRPhase(locale)); + fail("in" + attrs + "/" + elem + " / " + xpath + ": Unexpected exception: " + iae); } } }