def create_test_card(fields: Optional[Dict[str, Any]] = None) -> Card: """ Creates a test card with fields from the given dict :param fields: The fields to populate :return: A card object """ card = Card() card.scryfall_oracle_id = uuid.uuid4() card.name = uuid.uuid1() card.cmc = 0 card.num_power = 0 card.num_toughness = 0 card.num_loyalty = 0 card.colour_flags = 0 card.colour_identity_flags = 0 card.colour_count = 0 card.colour_identity_count = 0 card.colour_sort_key = 0 card.colour_weight = 0 card.layout = "normal" card.is_reserved = False card.is_token = False card.converted_mana_cost = 0 for key, value in (fields or {}).items(): assert hasattr(card, key) setattr(card, key, value) card.full_clean() card.save() return card