Пример #1
0
 def criteriaUsed(self):
     """ Test that the condition is false, if the criteria limits the matches below the required number """
     name = "Test Name"
     cards = [BuildCard(name=name) for i in range(10)]
     event = CardsEvent(cards, None, BuildPlayerContext())
     result = Matching(EVENT, criteria=FixedCriteria("name", name, "!=")).evaluate(event.context)
     self.assertFalse(result, "The Condition should be false, if the criteria limits the matching cards")
Пример #2
0
    def isNotUnique(self):
        """ Test that a event without the specified unique field returns false """
        playedSource = self.event.context.loadSource(PLAYED)
        playedSource.add(BuildCard(self.name))

        result = Unique(self.field, PLAYED).evaluate(self.event.context)
        self.assertFalse(
            result,
            "When the Event card does have the specified field as unique, the condition should be false"
        )
Пример #3
0
    def isUnique(self):
        """ Test that a event with the specified unique field returns true """
        playedSource = self.event.context.loadSource(PLAYED)
        playedSource.add(BuildCard(self.name + "Gibberish"))

        result = Unique(self.field, PLAYED).evaluate(self.event.context)
        self.assertTrue(
            result,
            "When the Event card has the specified field as unique, the condition should be true"
        )
Пример #4
0
    def isNotNthUnique(self):
        """ Test that the condition is false when the card is not the nth unique card played """
        n = 2
        playedSource = self.event.context.loadSource(PLAYED)
        [playedSource.add(BuildCard(self.name)) for i in range(n - 1)]

        result = NthUnique(n, []).evaluate(self.event.context)
        self.assertFalse(
            result,
            "When the Event card matches the criteria and is not the nth uniquely named card, the condition should be false"
        )
Пример #5
0
    def isNthPlayed(self):
        """ Test that the condition is true when the card is the nth one played """
        n = 3
        playedSource = self.event.context.loadSource(PLAYED)
        [playedSource.add(BuildCard(self.name)) for i in range(n - 1)]

        result = NthPlayed(n, FixedCriteria("name", self.name,
                                            "==")).evaluate(self.event.context)
        self.assertTrue(
            result,
            "When the Event card matches the criteria and is the nth card, the condition should be true"
        )
Пример #6
0
class play(unittest.TestCase):
    """ Test cases of play """
    
    def  setUp(self):
        """ Build the Card for the test """
        self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)])
        
    def playEffectsPerformed(self):
        """ Test that the card play effects were performed """
        coroutine = self.card.play(BuildGame())
        self.assertRaises(StopIteration, coroutine.next)
        self.assertTrue(all([effect.performed for effect in self.card.playEffects]), "All the effects should be performed")
Пример #7
0
class play(unittest.TestCase):
    """ Test cases of play """
    def setUp(self):
        """ Build the Card for the test """
        self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)])

    def playEffectsPerformed(self):
        """ Test that the card play effects were performed """
        coroutine = self.card.play(BuildGame())
        self.assertRaises(StopIteration, coroutine.next)
        self.assertTrue(
            all([effect.performed for effect in self.card.playEffects]),
            "All the effects should be performed")
Пример #8
0
    def notMatchingCriteria(self):
        """ Test that the condition is false when the card is not the nth unique card played """
        n = 3
        type = self.cardType + "Gibberish"
        playedSource = self.event.context.loadSource(PLAYED)
        [
            playedSource.add(BuildCard(self.name + str(i), cardType=type))
            for i in range(n - 1)
        ]

        result = NthUnique(n,
                           [FixedCriteria("cardType", type, "==")]).evaluate(
                               self.event.context)
        self.assertFalse(
            result,
            "When the Event card does not match the criteria and is the nth uniquely named card, the condition should be false"
        )
Пример #9
0
 def setUp(self):
     """ Build the Context for the test """
     self.name = "Test Name"
     self.event = CardsEvent([BuildCard(self.name)], None,
                             BuildPlayerContext())
Пример #10
0
 def setUp(self):
     """ Build the Card for the test """
     self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)])
Пример #11
0
 def  setUp(self):
     """ Build the Card for the test """
     self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)])
Пример #12
0
 def invalid(self):
     """ Test that the comparison returns invalid """
     cardToCompareAgainst = BuildCard(name=self.cardName+"Gibberish")
     isValid = self.criteria.compare(cardToCompareAgainst, self.context)
     self.assertFalse(isValid, "The Comparison should not be valid when the field value is set differently")
Пример #13
0
 def valid(self):
     """ Test that the comparison can return valid if the cards in the zone are properly set """
     cardToCompareAgainst = BuildCard(name=self.cardName)
     isValid = self.criteria.compare(cardToCompareAgainst, self.context)
     self.assertTrue(isValid, "The Comparison should be valid when the field value is set properly")
Пример #14
0
 def  setUp(self):
     """ Build the Zone and Criteria for the test """
     self.cardName = "Blah Blah"
     cardsEvent = CardsEvent([BuildCard(name=self.cardName)], None, BuildPlayerContext())
     self.context = cardsEvent.context
     self.criteria = ZoneCriteria("name", EVENT)
Пример #15
0
 def setUp(self):
     """ Build the Card and Criteria for the test """
     self.cardName = "Blah Blah"
     self.card = BuildCard(name=self.cardName)
Пример #16
0
 def setUp(self):
     """ Build the Filter for the test """
     self.cardName = "Blah Blah"
     self.cards = [BuildCard(name=self.cardName) for i in range(10)]
     cardsEvent = CardsEvent(self.cards, None, BuildPlayerContext())
     self.context = cardsEvent.context
Пример #17
0
 def setUp(self):
     """ Build the Event for the test """
     self.name = "Test Name"
     self.cardType = "A Type"
     self.event = CardsEvent([BuildCard(self.name, cardType=self.cardType)],
                             None, BuildPlayerContext())