unit test validator

This commit is contained in:
montezdesousa
2024-02-12 18:35:28 +00:00
parent 5a63383572
commit 1644cacd00

View 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