-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Sandbox-configuration
- Loading branch information
Showing
12 changed files
with
90 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,4 @@ scrap/ | |
.DS_Store | ||
.vscode/ | ||
.ruff_cache/ | ||
.python-version |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
import pytest | ||
from healthchain.models.data.concept import Quantity | ||
from pydantic import ValidationError | ||
|
||
|
||
# Valid Cases | ||
def test_valid(): | ||
valid_floats = [1.0, 0.1, 4.5, 5.99999, 12455.321, 33, 1234, None] | ||
for num in valid_floats: | ||
q = Quantity(value=num, unit="mg") | ||
assert q.value == num | ||
|
||
|
||
def test_valid_string(): | ||
valid_strings = ["100", "100.000001", ".1", "1.", ".123", "1234.", "123989"] | ||
for string in valid_strings: | ||
q = Quantity(value=string, unit="mg") | ||
assert q.value == float(string) | ||
|
||
|
||
# Invalid Cases | ||
def test_invalid_strings(): | ||
invalid_strings = [ | ||
"1.0.0", | ||
"1..123", | ||
"..123", | ||
"12..", | ||
"12a.56", | ||
"1e4.6", | ||
"12#.45", | ||
"12.12@3", | ||
"12@3", | ||
"abc", | ||
"None", | ||
"", | ||
] | ||
for string in invalid_strings: | ||
with pytest.raises(ValidationError) as exception_info: | ||
Quantity(value=string, unit="mg") | ||
assert "Invalid value" in str(exception_info.value) |