mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
unit test validator
This commit is contained in:
22
openbb_platform/core/tests/provider/utils/test_validators.py
Normal file
22
openbb_platform/core/tests/provider/utils/test_validators.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Test the provider validators."""
|
||||
|
||||
import pytest
|
||||
from openbb_core.provider.utils.validators import check_single_value
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field, value, expected",
|
||||
[
|
||||
("test", "SYMBOL", "SYMBOL"),
|
||||
("test", None, None),
|
||||
("test", "", ""),
|
||||
("test", "SYMBOL1,SYMBOL2", ValueError),
|
||||
("test", "SYMBOL1;SYMBOL2", ValueError),
|
||||
],
|
||||
)
|
||||
def test_check_single_value(field, value, expected):
|
||||
if expected == ValueError:
|
||||
with pytest.raises(ValueError):
|
||||
check_single_value(field, value)
|
||||
else:
|
||||
assert check_single_value(field, value) == expected
|
||||
Reference in New Issue
Block a user