Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
test(contacts): add direct unit tests for vcard _escape/_unescape (#243)
Peace. Ac95fed42dbc3
diff --git a/tests/unit/contacts/test_vcard.py b/tests/unit/contacts/test_vcard.pyindex da636d4e67..f72c5acc47 100644--- a/tests/unit/contacts/test_vcard.py+++ b/tests/unit/contacts/test_vcard.py@@ -15,6 +15,8 @@ import pytestfrom jarvis.contacts.store import ContactStorefrom jarvis.contacts.vcard import (+ _escape,+ _unescape,contact_to_vcard,contacts_to_vcf,import_records,@@ -203,3 +205,67 @@ def test_skipped_record_keeps_personal_data_out_of_the_log(assert "skipped a record" in caplog.textassert "Private Person" not in caplog.textassert "1990-99-99" not in caplog.text+++# ----------------------------------------------------------------------+# TEXT value escaping: direct tests for _escape / _unescape+# ----------------------------------------------------------------------+++ ("raw", "escaped"),+ [+ ("a,b", "a\\,b"),+ ("a;b", "a\\;b"),+ ("a\\b", "a\\\\b"),+ ("a\nb", "a\\nb"),+ ("plain text", "plain text"),+ ("", ""),+ ],+)+def test_escape_single_special_character(raw: str, escaped: str) -> None:+ assert _escape(raw) == escaped+++def test_escape_all_four_specials_combined() -> None:+ # Backslash is escaped first, so the backslashes added for the other+ # three characters are not doubled.+ assert _escape("\\,;\n") == "\\\\" + "\\," + "\\;" + "\\n"+++ ("escaped", "raw"),+ [+ ("a\\nb", "a\nb"),+ ("a\\Nb", "a\nb"),+ ("a\\,b", "a,b"),+ ("a\\;b", "a;b"),+ ("a\\\\b", "a\\b"),+ ("a\\xb", "axb"),+ ("plain text", "plain text"),+ ("", ""),+ ],+)+def test_unescape_sequences(escaped: str, raw: str) -> None:+ assert _unescape(escaped) == raw+++def test_unescape_trailing_lone_backslash_is_kept() -> None:+ assert _unescape("abc\\") == "abc\\"+++def test_unescape_escaped_backslash_before_n_is_not_a_newline() -> None:+ assert _unescape("\\\\n") == "\\n"+++def test_unescape_odd_run_of_backslashes() -> None:+ # Two backslashes collapse to one; the third has nothing after it and stays.+ assert _unescape("\\\\\\") == "\\\\"+++ "value",+ ["a\\b,c;d\ne", ",;\\\n", "\\n", "\\\\", ""],+)+def test_escape_unescape_roundtrip(value: str) -> None:+ assert _unescape(_escape(value)) == value