-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feito validação para probabilidade de chuva
- Loading branch information
Showing
9 changed files
with
63 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
[Ss]cripts | ||
pyvenv.cfg | ||
.venv | ||
.env | ||
venv/ | ||
.idea/ | ||
.vscode/ | ||
|
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
language: python | ||
python: | ||
- '3.6' | ||
- '3.6' | ||
- '3.7' | ||
sudo: required | ||
install: | ||
- pip install -r requirements.txt | ||
|
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,14 @@ | ||
def rain_probability(value): | ||
try: | ||
result = __validate_rain_probability(value) | ||
except ValueError: | ||
result = None | ||
return result | ||
|
||
|
||
def __validate_rain_probability(value): | ||
to_validate = float(value) | ||
if 0 <= to_validate <= 100: | ||
return to_validate | ||
elif str(to_validate).isdigit() and (0 <= float(to_validate) <= 100): | ||
return float(to_validate) |
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
unidecode | ||
lxml | ||
mongo | ||
pymongo | ||
Flask-PyMongo | ||
beautifulsoup4 | ||
Flask | ||
flask_cors | ||
|
Empty file.
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,39 @@ | ||
import unittest | ||
|
||
from api.services.weatherValidator import rain_probability | ||
|
||
|
||
class MyTestCase(unittest.TestCase): | ||
def test_rain_probability_negative_integer(self): | ||
self.assertEqual(None, rain_probability(-1)) | ||
|
||
def test_rain_probability_negative_float(self): | ||
self.assertEqual(None, rain_probability(-1.1)) | ||
|
||
def test_rain_probability_negative_string(self): | ||
self.assertEqual(None, rain_probability('-1')) | ||
|
||
def test_rain_probability_over_100_integer(self): | ||
self.assertEqual(None, rain_probability(101)) | ||
|
||
def test_rain_probability_over_100_float(self): | ||
self.assertEqual(None, rain_probability(101.1)) | ||
|
||
def test_rain_probability_over_100_string(self): | ||
self.assertEqual(None, rain_probability('101')) | ||
|
||
def test_rain_probability_string_not_digit(self): | ||
self.assertEqual(None, rain_probability('aaaaaa1212')) | ||
|
||
def test_rain_probability_in_interval_integer(self): | ||
self.assertEqual(12, rain_probability(12)) | ||
|
||
def test_rain_probability_in_interval_float(self): | ||
self.assertEqual(12.34, rain_probability(12.34)) | ||
|
||
def test_rain_probability_in_interval_string(self): | ||
self.assertEqual(54.121, rain_probability('54.121')) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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