Ejemplo n.º 1
0
    def test_bid_suggestion_name_length(self):
        parent_bid = models.Bid(name='Parent bid', speedrun=self.run)

        # A suggestion for a parent bid with no max length should be okay
        child = models.Bid(parent=parent_bid, name='quite a long name')
        child.clean()

        # A suggestion with a too long name should fail validation
        parent_bid.option_max_length = 5
        child = models.Bid(parent=parent_bid, name='too long')
        with self.assertRaises(ValidationError):
            child.clean()

        # A suggestion with okay name should pass validation
        child = models.Bid(parent=parent_bid, name='short')
        child.clean()
Ejemplo n.º 2
0
 def test_bid_option_max_length_require(self):
     # A bid cannot set option_max_length if allowuseroptions is not set
     bid = models.Bid(name='I am a bid', option_max_length=1)
     with self.assertRaisesRegex(
         ValidationError, 'Cannot set option_max_length without allowuseroptions'
     ):
         bid.clean()