def setUp(self) -> None: self.set_obj = create_test_set("Setty", "SET", {}) self.red_card = create_test_card({"colour_flags": Colour.RED}) self.red_card_printing = create_test_card_printing( self.red_card, self.set_obj, {}) self.green_card = create_test_card({"colour_flags": Colour.GREEN}) self.green_card_printing = create_test_card_printing( self.green_card, self.set_obj, {}) self.red_green_card = create_test_card() create_test_card_face(self.red_green_card, {"colour": Colour.RED | Colour.GREEN}) self.red_green_card_printing = create_test_card_printing( self.red_green_card, self.set_obj, {}) self.red_green_black_card = create_test_card() create_test_card_face( self.red_green_black_card, {"colour": Colour.RED | Colour.GREEN | Colour.BLACK}, ) self.red_green_black_card_printing = create_test_card_printing( self.red_green_black_card, self.set_obj, {}) self.blue_red_card = create_test_card( {"colour_flags": Colour.BLUE | Colour.RED}) self.blue_red_card_printing = create_test_card_printing( self.blue_red_card, self.set_obj, {}) self.parse_search = ParseSearch()
def test_set_match(self): """ Tests that a card in a set can be found with this param """ card = create_test_card({}) set_obj = create_test_set('Foobar', 'FOO', {}) create_test_card_printing(card, set_obj, {}) param = CardSetParam(Set.objects.get(code='FOO')) self.assertIn(card, Card.objects.filter(param.query()))
def test_name_not_contains(self) -> None: """ Test that a card name that doesn't match isn't found """ card = create_test_card({"name": "foo"}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardNameParam("bar", match_exact=False) self.assertNotIn(printing, CardPrinting.objects.filter(param.query()))
def test_name_contains_no_match(self) -> None: """ Tests that a card name exact match is found """ card = create_test_card({"name": "foobar"}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardNameParam("foo", match_exact=True) self.assertNotIn(printing, CardPrinting.objects.filter(param.query()))
def test_set_match(self) -> None: """ Tests that a card in a set can be found with this param """ card = create_test_card({}) set_obj = create_test_set("Foobar", "FOO", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardSetParam(Set.objects.get(code="FOO")) self.assertIn(printing, CardPrinting.objects.filter(param.query()))
def test_rules_blank(self) -> None: """ Tests that a card without text won't be found by a param with content """ card = create_test_card({}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardRulesTextParam("Vigilance") self.assertNotIn(printing, CardPrinting.objects.filter(param.query()))
def test_rules_contains(self) -> None: """ Tests that the rules param will match cards that contain the text """ card = create_test_card() create_test_card_face(card, {"rules_text": "Double strike"}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardRulesTextParam("strike") self.assertIn(printing, CardPrinting.objects.filter(param.query()))
def test_rules_match(self) -> None: """ Tests that the rules param will match cards that have the exact text :return: """ card = create_test_card() create_test_card_face(card, {"rules_text": "Flying"}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardRulesTextParam("Flying") self.assertIn(printing, CardPrinting.objects.filter(param.query()))
def test_name_match_invert(self) -> None: """ Tests that """ root_param = AndParam() root_param.negated = True card = create_test_card({"name": "foo"}) set_obj = create_test_set("Setty", "SET", {}) printing = create_test_card_printing(card, set_obj, {}) param = CardNameParam("bar") root_param.add_parameter(param) self.assertIn(printing, CardPrinting.objects.filter(root_param.query()))
def test_set_match(self): card = create_test_card({}) set_obj = create_test_set('Foobar', 'FOO') printing = create_test_card_printing(card, set_obj) param = CardSetParam(Set.objects.get(code='FOO')) self.assertIn(card, param.get_result())