This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase infra_fail_job_index limit.
Summary: Arguably should be using `paginate`, but that'd require a schema/UI change, and this is very easy. Test Plan: None Reviewers: naphat Reviewed By: naphat Subscribers: changesbot, anupc Differential Revision: https://tails.corp.dropbox.com/D231183
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Callable # NOQA | ||
|
||
|
||
def bounded_integer(lower, upper): | ||
"""Accepts an integer in [lower, upper].""" | ||
# type: (int, int) -> Callable[str, int] | ||
def parse(s): | ||
# type: (str) -> int | ||
iv = int(s) | ||
if iv < lower or iv > upper: | ||
raise ValueError("{} is not in [{}, {}]".format(iv, lower, upper)) | ||
return iv | ||
return parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from changes.api.validators.basic import bounded_integer | ||
|
||
|
||
def test_bounded_integer(): | ||
validator = bounded_integer(0, 10) | ||
with pytest.raises(ValueError): | ||
validator("11") | ||
|
||
with pytest.raises(ValueError): | ||
validator("4.5") | ||
|
||
with pytest.raises(ValueError): | ||
validator("-3") | ||
|
||
with pytest.raises(ValueError): | ||
validator("") | ||
|
||
with pytest.raises(ValueError): | ||
validator("10000") | ||
|
||
# No error expeceted | ||
validator("0") | ||
validator("2") | ||
validator("9") | ||
validator("10") |