Merge pull request #67 from aguzererler/testing/cli-extract-content-string-6775172434327225745

🧪 [Testing Improvement] Add tests for `extract_content_string` in `cli/main.py`
This commit is contained in:
ahmet guzererler 2026-03-21 17:27:21 +01:00 committed by GitHub
commit 0dc6236e20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 0 deletions

27
tests/cli/test_main.py Normal file
View File

@ -0,0 +1,27 @@
import pytest
from cli.main import extract_content_string
def test_extract_content_string_empty():
assert extract_content_string(None) is None
assert extract_content_string("") is None
assert extract_content_string(" ") is None
def test_extract_content_string_valid_eval():
assert extract_content_string("[]") is None
assert extract_content_string("{}") is None
assert extract_content_string('""') is None
def test_extract_content_string_invalid_eval_valueerror():
# simulating ValueError in literal_eval
assert extract_content_string("not_a_valid_python_literal") == "not_a_valid_python_literal"
def test_extract_content_string_invalid_eval_syntaxerror():
# simulating SyntaxError in literal_eval
assert extract_content_string("{[}") == "{[}"
def test_extract_content_string_dict():
assert extract_content_string({"text": "hello"}) == "hello"
assert extract_content_string({"text": " "}) is None
def test_extract_content_string_list():
assert extract_content_string([{"type": "text", "text": "hello"}, " world"]) == "hello world"