55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
"""Unit tests for devx.utils.api."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from devx.utils.api import is_falsy, is_truthy
|
|
|
|
|
|
class TestIsTruthy:
|
|
def test_string_true(self) -> None:
|
|
assert is_truthy("true") is True
|
|
|
|
def test_string_true_uppercase(self) -> None:
|
|
assert is_truthy("True") is True
|
|
|
|
def test_boolean_true(self) -> None:
|
|
assert is_truthy(True) is True
|
|
|
|
def test_string_false(self) -> None:
|
|
assert is_truthy("false") is False
|
|
|
|
def test_boolean_false(self) -> None:
|
|
assert is_truthy(False) is False
|
|
|
|
def test_none(self) -> None:
|
|
assert is_truthy(None) is False
|
|
|
|
def test_empty_string(self) -> None:
|
|
assert is_truthy("") is False
|
|
|
|
def test_random_string(self) -> None:
|
|
assert is_truthy("random") is False
|
|
|
|
|
|
class TestIsFalsy:
|
|
def test_string_false(self) -> None:
|
|
assert is_falsy("false") is True
|
|
|
|
def test_string_false_uppercase(self) -> None:
|
|
assert is_falsy("False") is True
|
|
|
|
def test_boolean_false(self) -> None:
|
|
assert is_falsy(False) is True
|
|
|
|
def test_string_true(self) -> None:
|
|
assert is_falsy("true") is False
|
|
|
|
def test_boolean_true(self) -> None:
|
|
assert is_falsy(True) is False
|
|
|
|
def test_none(self) -> None:
|
|
assert is_falsy(None) is False
|
|
|
|
def test_empty_string(self) -> None:
|
|
assert is_falsy("") is False
|