mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
Tests: added verify test to check wrong scryfall download settings;
This commit is contained in:
parent
450646ca5e
commit
fbcdeeb2a8
1 changed files with 40 additions and 10 deletions
|
@ -26,6 +26,7 @@ import org.apache.log4j.Logger;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
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.CardDownloadData;
|
||||||
import org.mage.plugins.card.images.DownloadPicturesService;
|
import org.mage.plugins.card.images.DownloadPicturesService;
|
||||||
import org.reflections.Reflections;
|
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_MISSING_ABILITIES = "MISSING_ABILITIES";
|
||||||
private static final String SKIP_LIST_DOUBLE_RARE = "DOUBLE_RARE";
|
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_INVALID_SETS = "INVALID_SETS";
|
||||||
|
private static final String SKIP_LIST_SCRYFALL_DOWNLOAD_SETS = "SCRYFALL_DOWNLOAD_SETS";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// skip lists for checks (example: unstable cards with same name may have different stats)
|
// 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, "AMH1"); // Modern Horizons Art Series
|
||||||
skipListAddName(SKIP_LIST_INVALID_SETS, "PTG"); // Ponies: The Galloping
|
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) {
|
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
|
// 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) {
|
if (errorsList.size() > 0) {
|
||||||
Assert.fail("DB has wrong card classes, found errors: " + errorsList.size());
|
Assert.fail("DB has wrong card classes, found errors: " + errorsList.size());
|
||||||
}
|
}
|
||||||
|
@ -409,9 +411,7 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// only warnings
|
// only warnings
|
||||||
for (String error : errorsList) {
|
printMessages(errorsList);
|
||||||
System.out.println(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -444,8 +444,8 @@ public class VerifyCardDataTest {
|
||||||
DeckCardLists deckCards = DeckImporter.importDeckFromFile(deckFile.toString(), deckErrors);
|
DeckCardLists deckCards = DeckImporter.importDeckFromFile(deckFile.toString(), deckErrors);
|
||||||
|
|
||||||
if (!deckErrors.toString().isEmpty()) {
|
if (!deckErrors.toString().isEmpty()) {
|
||||||
errorsList.add("Error: sample contains errors " + deckName);
|
errorsList.add("Error: sample deck contains errors " + deckName);
|
||||||
System.out.println("Errors in sample file " + deckName + ":\n" + deckErrors.toString());
|
System.out.println("Errors in sample deck " + deckName + ":\n" + deckErrors.toString());
|
||||||
totalErrorFiles++;
|
totalErrorFiles++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -463,6 +463,36 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_checkMissingScryfallSettings() {
|
||||||
|
Collection<String> errorsList = new ArrayList<>();
|
||||||
|
|
||||||
|
Collection<ExpansionSet> xmageSets = Sets.getInstance().values();
|
||||||
|
Set<String> 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) {
|
private Object createNewObject(Class<?> clazz) {
|
||||||
try {
|
try {
|
||||||
Constructor<?> cons = clazz.getConstructor();
|
Constructor<?> cons = clazz.getConstructor();
|
||||||
|
|
Loading…
Reference in a new issue