Exemple #1
0
 def test_cant_start_match_if_teams_have_different_number_of_players(self):
     referee = factories.RefereeFactory()
     match = factories.MatchFactory(
         first_team__players__count=3,
         second_team__players__count=5)
     with self.shouldRaiseException(MatchErrors.CANT_START_NOT_EVEN_TEAMS):
         logic.can_start_match(referee, match)
Exemple #2
0
def start_match(match, observer, referee):
    # here is example how you can check certain validator without raising exception
    observer_can_start_match = logic.can_start_match(observer, match, raise_exception=False)

    # observer_can_start_match is a `ValidationResult` object.
    # It contains information about success and error.

    # Due to logic, I know that observer_can_start_match will be false, but let's check
    if not observer_can_start_match:
        print(u"{} can't start match, reason: {}".format(observer, str(observer_can_start_match)))

    # This will pass without exception, it's valid case
    logic.start_match(referee, match, validate=True)
Exemple #3
0
 def test_cant_start_match_if_already_started(self):
     referee = factories.RefereeFactory()
     match = factories.MatchFactory(status=models.Match.STARTED)
     with self.shouldRaiseException(MatchErrors.CANT_START_ALREADY_STARTED):
         logic.can_start_match(referee, match)
Exemple #4
0
 def test_not_referee_cant_start_match(self):
     person = factories.PersonFactory()
     match = factories.MatchFactory()
     with self.shouldRaiseException(MatchErrors.CANT_START_NOT_REFEREE):
         logic.can_start_match(person, match)