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()
Exemple #2
0
 def test_name_contains(self):
     """
     Tests that a card name containing is found
     """
     card = create_test_card({'name': 'foobar'})
     param = CardNameParam('foo')
     self.assertIn(card, Card.objects.filter(param.query()))
Exemple #3
0
 def test_name_not_contains(self):
     """
     Test that a card name that doesn't match isn't found
     """
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('bar')
     self.assertNotIn(card, Card.objects.filter(param.query()))
Exemple #4
0
 def test_rules_contains(self):
     """
     Tests that the rules param will match cards that contain the text
     """
     card = create_test_card({'rules_text': 'Double Strike'})
     param = CardRulesTextParam('strike')
     self.assertIn(card, Card.objects.filter(param.query()))
Exemple #5
0
 def test_rules_blank(self):
     """
     Tests that a card without text won't be found by a param with content
     """
     card = create_test_card({})
     param = CardRulesTextParam('Vigilance')
     self.assertNotIn(card, Card.objects.filter(param.query()))
Exemple #6
0
 def test_name_match(self):
     """
     Tests that a card name exact match is found
     """
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('foo')
     self.assertIn(card, Card.objects.filter(param.query()))
Exemple #7
0
 def test_rules_match(self):
     """
     Tests that the rules param will match cards that have the exact text
     :return:
     """
     card = create_test_card({'rules_text': 'Flying'})
     param = CardRulesTextParam('Flying')
     self.assertIn(card, Card.objects.filter(param.query()))
Exemple #8
0
 def test_name_match_invert(self):
     """
     Tests that
     """
     root_param = AndParam(True)
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('bar')
     root_param.add_parameter(param)
     self.assertIn(card, Card.objects.filter(root_param.query()))
Exemple #9
0
 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()))
Exemple #10
0
 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()))
Exemple #11
0
 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()))
Exemple #12
0
 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()))
Exemple #13
0
 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()))
Exemple #14
0
 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()))
Exemple #15
0
 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()))
Exemple #16
0
 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()))
Exemple #17
0
 def test_rules_match(self):
     card = create_test_card({'rules_text': 'Flying'})
     param = CardRulesTextParam('Flying')
     self.assertIn(card, param.get_result())
Exemple #18
0
 def test_name_match_invert(self):
     root_param = NotParam()
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('bar')
     root_param.add_parameter(param)
     self.assertIn(card, root_param.get_result())
Exemple #19
0
 def test_rules_contains(self):
     card = create_test_card({'rules_text': 'Double Strike'})
     param = CardRulesTextParam('strike')
     self.assertIn(card, param.get_result())
Exemple #20
0
 def test_name_not_contains(self):
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('bar')
     self.assertNotIn(card, param.get_result())
Exemple #21
0
 def test_rules_blank(self):
     card = create_test_card({})
     param = CardRulesTextParam('Vigilance')
     self.assertNotIn(card, param.get_result())
Exemple #22
0
 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())
Exemple #23
0
 def test_name_match(self):
     card = create_test_card({'name': 'foo'})
     param = CardNameParam('foo')
     self.assertIn(card, param.get_result())