Skip to content

Commit

Permalink
bug 1282841: can't set background rate to 0 for new rules (#189). r=b…
Browse files Browse the repository at this point in the history
…hearsum
  • Loading branch information
Tomislav authored and bhearsum committed Dec 20, 2016
1 parent f379a80 commit 20afea5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion auslib/admin/views/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from auslib.util.timestamp import getMillisecondTimestamp
from auslib.util.versions import MozillaVersion


import logging
log = logging.getLogger(__name__)

Expand Down Expand Up @@ -168,7 +169,7 @@ class PartialReleaseForm(Form):


class RuleForm(Form):
backgroundRate = IntegerField('Background Rate', validators=[Required(), NumberRange(0, 100)])
backgroundRate = IntegerField('Background Rate', validators=[NumberRange(0, 100, "Background rate must be between 0 and 100")])
priority = IntegerField('Priority', validators=[Required()])
mapping = SelectField('Mapping', validators=[])
fallbackMapping = NullableStringField('fallbackMapping', validators=[Optional()])
Expand Down
11 changes: 11 additions & 0 deletions auslib/test/admin/views/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def testNewRulePost(self):
self.assertEquals(r[0]['priority'], 33)
self.assertEquals(r[0]['data_version'], 1)

def testBackgroundRateZero(self):
ret = self._post('/rules', data=dict(backgroundRate=0, mapping='c', priority=33,
product='Firefox', update_type='minor', channel='nightly'))
self.assertEquals(ret.status_code, 200, "Status Code: %d, Data: %s" % (ret.status_code, ret.data))
r = dbo.rules.t.select().where(dbo.rules.rule_id == ret.data).execute().fetchall()
self.assertEquals(len(r), 1)
self.assertEquals(r[0]['mapping'], 'c')
self.assertEquals(r[0]['backgroundRate'], 0)
self.assertEquals(r[0]['priority'], 33)
self.assertEquals(r[0]['data_version'], 1)

def testNewRulePostJSON(self):
data = dict(
backgroundRate=31, mapping="c", priority=33, product="Firefox",
Expand Down

0 comments on commit 20afea5

Please sign in to comment.