Skip to content

Commit

Permalink
Bug 1324799 - Able to set priority to 0 for new rules (mozilla-releng…
Browse files Browse the repository at this point in the history
…#235). r=bhearsum
  • Loading branch information
aksareen authored and bhearsum committed Feb 3, 2017
1 parent c1ed454 commit da8f5c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion auslib/admin/views/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class PartialReleaseForm(Form):

class RuleForm(Form):
backgroundRate = IntegerField('Background Rate', validators=[NumberRange(0, 100, "Background rate must be between 0 and 100")])
priority = IntegerField('Priority', validators=[InputRequired()])
priority = IntegerField('Priority', validators=[NumberRange(min=0, message="Priority must be a non-negative integer")])
mapping = SelectField('Mapping', validators=[])
fallbackMapping = NullableStringField('fallbackMapping', validators=[Optional()])
alias = NullableStringField('Alias', validators=[Length(0, 50), Regexp(RULE_ALIAS_REGEXP)])
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 @@ -47,6 +47,17 @@ def testBackgroundRateZero(self):
self.assertEquals(r[0]['priority'], 33)
self.assertEquals(r[0]['data_version'], 1)

def testPriorityZero(self):
ret = self._post('/rules', data=dict(backgroundRate=33, mapping='c', priority=0,
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'], 33)
self.assertEquals(r[0]['priority'], 0)
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 da8f5c0

Please sign in to comment.