def test_cardread(): num_cards_expected = 647 options = main.parse_opts([]) options.data_path = "." cards = main.read_card_data(options) assert len(cards) == num_cards_expected valid_cardsets = { u"base", u"dominion1stEdition", u"dominion2ndEdition", u"dominion2ndEditionUpgrade", u"intrigue1stEdition", u"intrigue2ndEdition", u"intrigue2ndEditionUpgrade", u"seaside", u"alchemy", u"prosperity", u"cornucopia extras", u"cornucopia", u"hinterlands", u"dark ages", u"dark ages extras", u"guilds", u"adventures", u"adventures extras", u"empires", u"empires extras", u"nocturne", u"nocturne extras", u"promo", u"renaissance", u"menagerie", u"extras", u"animals", } for c in cards: assert isinstance(c, domdiv_cards.Card) assert c.cardset_tag in valid_cardsets # Option modified card count options = main.parse_opts( ["--no-trash", "--curse10", "--start-decks", "--include-blanks", "7"] ) options = main.clean_opts(options) options.data_path = "." cards = main.read_card_data(options) # Total delta cards is +28 from # Trash: -1 * 3 sets = -3 # Curse: +2 * 4 sets = +8 # Start Decks: +4 * 4 sets = +16 # Blanks: +7 = +7 assert len(cards) == num_cards_expected + 28
def test_expansion_description_card_order(): # test that the expansions cards lists cards # in alphabetical order, like they are printed, # and that accents don't matter options = main.parse_opts([ "--expansions", "Hinterlands", "--expansion-dividers", "--language", "fr", "--only-type-any", "Expansion", ]) options = main.clean_opts(options) options.data_path = "." cards = main.read_card_data(options) cards = main.filter_sort_cards(cards, options) card_names = [c.strip() for c in cards[0].description.split("|")] # The 26 french card names of the Hinterlands expansion should be sorted as if no accent assert len(card_names) == 26 assert card_names == sorted( card_names, key=lambda s: "".join(c for c in unicodedata.normalize("NFD", s) if unicodedata.category(c) != "Mn"), )
def test_exclude_expansion(): # test that we can use --exclude-expansion or # --exclude-expansions, that we can have multiple # items with a single flag, that * syntax # works, that we can use either the # cardset tag or name, and that capitalization # doesn't matter options = main.parse_opts([ "--expansions", "adventures", "dominion*", "intrigue*", "--exclude-expansions", "dominiOn1stEditIon", "intrigue 2nd*", "--exclude-expansion", "dominion 2nd edition", ]) options = main.clean_opts(options) options.data_path = "." cards = main.read_card_data(options) cards = main.filter_sort_cards(cards, options) card_sets = set(x.cardset.lower() for x in cards) assert card_sets == { "adventures", "dominion 2nd edition upgrade", "intrigue 1st edition", }
def test_only_type(): options = main.parse_opts( [ "--expansions", "base", "alchemy", "--include-blanks", "5", "--only-type-any", "blank", "curse", "--only-type-all", "attack", "action", ] ) options = main.clean_opts(options) options.data_path = "." cards = main.read_card_data(options) cards = main.filter_sort_cards(cards, options) # Total 8 from # Blank: +5 added in options # Curse: +1 from base # Action Attack: +2 from Alchemy assert len(cards) == 8
def test_tab_edge_leftalt(): options = main.parse_opts( ["--tab-name-align", "edge", "--tab-side", "left-alternate"]) assert options.tab_name_align == "edge" assert options.tab_side == "left-alternate" main.calculate_layout(options) assert options.tab_name_align == "edge" assert options.tab_side == "left-alternate"
def test_tab_centre_full(): options = main.parse_opts( ["--tab-name-align", "centre", "--tab-side", "full"]) assert options.tab_name_align == "centre" assert options.tab_side == "full" main.calculate_layout(options) assert options.tab_name_align == "centre" assert options.tab_side == "full"
def test_tab_left_left(): options = main.parse_opts( ["--tab-name-align", "left", "--tab-side", "left"]) assert options.tab_name_align == "left" assert options.tab_side == "left" main.calculate_layout(options) assert options.tab_name_align == "left" assert options.tab_side == "left"
def test_tab_centre_rightalt(): options = main.parse_opts( ["--tab-name-align", "centre", "--tab-side", "right-alternate"]) assert options.tab_name_align == "centre" assert options.tab_side == "right-alternate" main.calculate_layout(options) assert options.tab_name_align == "centre" assert options.tab_side == "right-alternate"
def test_tab_edge_right(): options = main.parse_opts( ["--tab-name-align", "edge", "--tab-side", "right"]) assert options.tab_name_align == "edge" assert options.tab_side == "right" main.calculate_layout(options) assert options.tab_name_align == "edge" assert options.tab_side == "right"
def test_tab_edge_full(): options = main.parse_opts( ["--tab-name-align", "edge", "--tab-side", "full"]) assert options.tab_name_align == "edge" assert options.tab_side == "full" options = main.clean_opts(options) main.calculate_layout(options) assert options.tab_name_align == "left" # special check for odd condition assert options.tab_side == "full"
def test_tab_center_left(): options = main.parse_opts( ["--tab-name-align", "center", "--tab-side", "left"]) assert options.tab_name_align == "center" assert options.tab_side == "left" options = main.clean_opts(options) main.calculate_layout(options) assert options.tab_name_align == "centre" # check for change in value assert options.tab_side == "left"
def test_text_tabs_default(): # should be the default options = main.parse_opts([]) assert options.text_front == "card" assert options.text_back == "rules" assert options.tab_name_align == "left" assert options.tab_side == "right-alternate" main.calculate_layout(options) assert options.tab_name_align == "left"
def test_vertical(): options = main.parse_opts(["--orientation", "vertical"]) assert options.orientation == "vertical" main.calculate_layout(options) assert options.numDividersHorizontal == 3 assert options.numDividersVertical == 2 assert options.dividerWidth == 5.9 * cm assert options.labelHeight == 0.9 * cm assert options.dividerHeight == 9.1 * cm + options.labelHeight
def test_horizontal(): # should be the default options = main.parse_opts([]) assert options.orientation == "horizontal" main.calculate_layout(options) assert options.numDividersHorizontal == 2 assert options.numDividersVertical == 3 assert options.dividerWidth == 9.1 * cm assert options.labelHeight == 0.9 * cm assert options.dividerHeight == 5.9 * cm + options.labelHeight
def test_set_icon(): options = main.parse_opts([]) options = main.clean_opts(options) assert options.set_icon == ["tab"] options = main.parse_opts(["--set-icon=tab"]) options = main.clean_opts(options) assert options.set_icon == ["tab"] options = main.parse_opts(["--set-icon=body-top"]) options = main.clean_opts(options) assert options.set_icon == ["body-top"] options = main.parse_opts(["--set-icon=hide"]) options = main.clean_opts(options) assert options.set_icon == ["hide"] options = main.parse_opts(["--set-icon=tab", "--set-icon=body-top"]) options = main.clean_opts(options) assert set(options.set_icon) == {"tab", "body-top"}
def test_cost(): options = main.parse_opts([]) options = main.clean_opts(options) assert options.cost == ["tab"] options = main.parse_opts(["--cost=tab"]) options = main.clean_opts(options) assert options.cost == ["tab"] options = main.parse_opts(["--cost=body-top"]) options = main.clean_opts(options) assert options.cost == ["body-top"] options = main.parse_opts(["--cost=hide"]) options = main.clean_opts(options) assert options.cost == ["hide"] options = main.parse_opts(["--cost=tab", "--cost=body-top"]) options = main.clean_opts(options) assert set(options.cost) == {"tab", "body-top"}
def test_languages(): languages = main.get_languages("card_db") for lang in languages: print("checking " + lang) # for now, just test that they load options = main.parse_opts(["--language", lang]) options.data_path = "." cards = main.read_card_data(options) assert cards, '"{}" cards did not read properly'.format(lang) cards = main.add_card_text(cards, "en_us") cards = main.add_card_text(cards, lang) if lang == "it": assert "Maledizione" in [card.name for card in cards] elif lang == "de": assert "Fluch" in [card.name for card in cards]
def test_text_blank_rules(): options = main.parse_opts(["--front", "blank", "--back", "rules"]) assert options.text_front == "blank" assert options.text_back == "rules"
def test_text_rules_none(): options = main.parse_opts(["--front", "rules", "--back", "none"]) assert options.text_front == "rules" assert options.text_back == "none"
def test_sleeved(): options = main.parse_opts(["--size", "sleeved"]) main.calculate_layout(options) assert options.dividerWidth == 9.4 * cm assert options.labelHeight == 0.9 * cm assert options.dividerHeight == 6.15 * cm + options.labelHeight
def test_text_card_none(): options = main.parse_opts(["--front", "card", "--back", "none"]) assert options.text_front == "card" assert options.text_back == "none"
def test_text_blank_card(): options = main.parse_opts(["--front", "blank", "--back", "card"]) assert options.text_front == "blank" assert options.text_back == "card"
def test_text_blank_none(): options = main.parse_opts(["--front", "blank", "--back", "none"]) assert options.text_front == "blank" assert options.text_back == "none"
def test_text_card_rules(): options = main.parse_opts(["--front", "card", "--back", "rules"]) assert options.text_front == "card" assert options.text_back == "rules"