-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new max temperature constant * Revert "Add new max temperature constant" This reverts commit ac750e5. * Add max temperature constant * Add function to validate min and max values * Add test for validating values * Ignore coverage file * Remove coverage file * Simplify validator * Adjust tests * Add more tests * Add tests to ci workflow * Fix linting issues * Fix linting issues * Fix tests * Remove duplicated temperature * Remove duplicated radon * Validate all temperatures * Fix linting issue
- Loading branch information
Showing
6 changed files
with
68 additions
and
16 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
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
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,34 @@ | ||
import pytest | ||
|
||
from airthings_ble.parser import validate_value | ||
from airthings_ble.const import CO2_MAX, HUMIDITY_MAX, RADON_MAX | ||
|
||
|
||
def test_validate_value_humidity(): | ||
valid_humidity_values = [0, 50, 100.0] | ||
for value in valid_humidity_values: | ||
assert validate_value(value=value, max_value=HUMIDITY_MAX) == value | ||
|
||
invalid_humidity_values = [-1, 100.1, 101] | ||
for value in invalid_humidity_values: | ||
assert validate_value(value=value, max_value=HUMIDITY_MAX) is None | ||
|
||
|
||
def test_validate_value_radon(): | ||
valid_radon_values = [0, 100, 1000.0, 16383] | ||
for value in valid_radon_values: | ||
assert validate_value(value=value, max_value=RADON_MAX) == value | ||
|
||
invalid_radon_values = [-1, 16384, 65535] | ||
for value in invalid_radon_values: | ||
assert validate_value(value=value, max_value=RADON_MAX) is None | ||
|
||
|
||
def test_validate_value_co2(): | ||
valid_co2_values = [0, 100, 1000.0, 65534] | ||
for value in valid_co2_values: | ||
assert validate_value(value=value, max_value=CO2_MAX) == value | ||
|
||
invalid_co2_values = [-1, 65535] | ||
for value in invalid_co2_values: | ||
assert validate_value(value=value, max_value=CO2_MAX) is None |