Skip to content

Commit

Permalink
Merge pull request #2 from natanfeitosa/first-issue-solve
Browse files Browse the repository at this point in the history
Added functionality to resolve #1
  • Loading branch information
natanfeitosa authored Jan 19, 2023
2 parents 9d8b102 + 110adb0 commit 64ebfa6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `Number.nonpositive()` by [@natanfeitosa](https://github.com/natanfeitosa/) ([#1](https://github.com/natanfeitosa/kohi/issues/1))
- `Number.nonnegative()` by [@natanfeitosa](https://github.com/natanfeitosa/) ([#1](https://github.com/natanfeitosa/kohi/issues/1))

### Changed

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions kohi/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ def positive(self):

def negative(self):
return self.lt(0)

def nonpositive(self):
return self.lte(0)

def nonnegative(self):
return self.gte(0)
12 changes: 12 additions & 0 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ def test_negative():

assert not n.validate(1)
assert n.validate(-1)

def test_nonpositive():
n = NumberSchema().nonpositive()

assert not n.validate(1)
assert n.validate(-1)

def test_nonnegative():
n = NumberSchema().nonnegative()

assert n.validate(1)
assert not n.validate(-1)

0 comments on commit 64ebfa6

Please sign in to comment.