From fbcdeeb2a892181f4f9899db6084d5e47b13ccd5 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 8 Aug 2020 10:08:22 +0400 Subject: [PATCH] Tests: added verify test to check wrong scryfall download settings; --- .../java/mage/verify/VerifyCardDataTest.java | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index d821855a24..bcde89e549 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -26,6 +26,7 @@ import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; +import org.mage.plugins.card.dl.sources.ScryfallImageSupportCards; import org.mage.plugins.card.images.CardDownloadData; import org.mage.plugins.card.images.DownloadPicturesService; import org.reflections.Reflections; @@ -89,6 +90,7 @@ public class VerifyCardDataTest { private static final String SKIP_LIST_MISSING_ABILITIES = "MISSING_ABILITIES"; private static final String SKIP_LIST_DOUBLE_RARE = "DOUBLE_RARE"; private static final String SKIP_LIST_INVALID_SETS = "INVALID_SETS"; + private static final String SKIP_LIST_SCRYFALL_DOWNLOAD_SETS = "SCRYFALL_DOWNLOAD_SETS"; static { // skip lists for checks (example: unstable cards with same name may have different stats) @@ -196,6 +198,9 @@ public class VerifyCardDataTest { skipListAddName(SKIP_LIST_INVALID_SETS, "AMH1"); // Modern Horizons Art Series skipListAddName(SKIP_LIST_INVALID_SETS, "PTG"); // Ponies: The Galloping + // scryfall download sets (missing from scryfall website) + skipListCreate(SKIP_LIST_SCRYFALL_DOWNLOAD_SETS); + skipListAddName(SKIP_LIST_SCRYFALL_DOWNLOAD_SETS, "SWS"); // Star Wars } private void warn(Card card, String message) { @@ -370,13 +375,10 @@ public class VerifyCardDataTest { } } - for (String error : errorsList) { - System.out.println(error); - } - // unique cards stats - System.out.println("Total unique cards: " + classesIndex.size() + ", total non unique cards (reprints): " + totalCards); + errorsList.add("Total unique cards: " + classesIndex.size() + ", total non unique cards (reprints): " + totalCards); + printMessages(errorsList); if (errorsList.size() > 0) { Assert.fail("DB has wrong card classes, found errors: " + errorsList.size()); } @@ -409,9 +411,7 @@ public class VerifyCardDataTest { } // only warnings - for (String error : errorsList) { - System.out.println(error); - } + printMessages(errorsList); } @Test @@ -444,8 +444,8 @@ public class VerifyCardDataTest { DeckCardLists deckCards = DeckImporter.importDeckFromFile(deckFile.toString(), deckErrors); if (!deckErrors.toString().isEmpty()) { - errorsList.add("Error: sample contains errors " + deckName); - System.out.println("Errors in sample file " + deckName + ":\n" + deckErrors.toString()); + errorsList.add("Error: sample deck contains errors " + deckName); + System.out.println("Errors in sample deck " + deckName + ":\n" + deckErrors.toString()); totalErrorFiles++; continue; } @@ -463,6 +463,36 @@ public class VerifyCardDataTest { } } + @Test + public void test_checkMissingScryfallSettings() { + Collection errorsList = new ArrayList<>(); + + Collection xmageSets = Sets.getInstance().values(); + Set scryfallSets = ScryfallImageSupportCards.getSupportedSets(); + + // missing + for (ExpansionSet set : xmageSets) { + if (skipListHaveName(SKIP_LIST_SCRYFALL_DOWNLOAD_SETS, set.getCode())) + continue; + + if (!scryfallSets.contains(set.getCode())) { + errorsList.add("Error: scryfall download missing setting: " + set.getCode() + " - " + set.getName()); + } + } + + // unknown + for (String scryfallCode : scryfallSets) { + if (xmageSets.stream().noneMatch(e -> e.getCode().equals(scryfallCode))) { + errorsList.add("Error: scryfall download unknown setting: " + scryfallCode); + } + } + + printMessages(errorsList); + if (errorsList.size() > 0) { + Assert.fail("Found scryfall download errors: " + errorsList.size()); + } + } + private Object createNewObject(Class clazz) { try { Constructor cons = clazz.getConstructor();