Exemplo n.º 1
0
 def strike(self, player, points, foul=False):
     strike = Strike()
     strike.frame = self.frame
     strike.player = player
     strike.points = points
     strike.foul = foul
     strike.save()
     return strike
Exemplo n.º 2
0
class StrikeModelTest(TestCase):
    def setUp(self):
        basicSetUp(self)
        self.strike = Strike()
        self.strike.points = 1
        self.strike.player = self.player1
        self.strike.frame = self.frame
        self.strike.save()

    def test_simple_get_from_db(self):
        db_strike = Strike.objects.get(id=self.strike.id)
        self.assertEquals(db_strike, self.strike)

    def test_strike_player_not_in_match(self):
        player3 = Player()
        player3.name = 'third'
        player3.save()
        strike = Strike()
        strike.points = 1
        strike.frame = self.frame
        strike.player = player3
        self.assertRaises(ValidationError, strike.save)