Skip to content

Add regression tests for RichText serialization across all three supported shapes - #2611

Draft
Badiboy with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-code-review-comment
Draft

Add regression tests for RichText serialization across all three supported shapes#2611
Badiboy with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-code-review-comment

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown

RichText can be a plain string, a list, or a typed subclass — but no tests verified these shapes round-tripped correctly through InputRichMessage/InputRichBlock serialization. Subtypes with extra required fields (e.g. RichTextDateTime) were silently dropping those fields.

Changes

  • Merged RichText Dictionaryable support from PR Make RichText Dictionaryable #2610: adds to_dict() to all RichText subclasses and a RichText.richtext_to_dict() helper that dispatches across all three shapes; updates all InputRichBlock subclasses to use it instead of the direct .to_dict() call that broke on strings and lists.

  • Added regression tests in tests/test_types.py covering:

    • test_rich_text_plain_string_serialization — plain str through InputRichBlockParagraphInputRichMessage
    • test_rich_text_nested_list_serialization — mixed [str, RichTextBold] list
    • test_rich_text_nested_richtext_serialization — single RichTextBold object
    • test_rich_text_datetime_serializationRichTextDateTime asserting unix_time and date_time_format are present in output
# Previously would raise AttributeError or silently drop fields
dt = types.RichTextDateTime(text='Jan 1', unix_time=1740000000, date_time_format='short')
block = types.InputRichBlockParagraph(text=dt)
d = types.InputRichMessage(blocks=[block]).to_dict()
# Now correctly produces:
# {'blocks': [{'type': 'paragraph', 'text': {'type': 'date_time', 'text': 'Jan 1',
#              'unix_time': 1740000000, 'date_time_format': 'short'}}]}

Badiboy and others added 2 commits August 9, 2026 16:06
Make RichText Dictionaryable
Conform the fact that RichText can be str or list also.
Badiboy and others added 3 commits August 9, 2026 16:11
Co-authored-by: Badiboy <5613421+Badiboy@users.noreply.github.com>
… nested list, nested RichText, RichTextDateTime)

Co-authored-by: Badiboy <5613421+Badiboy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code according to review comment Add regression tests for RichText serialization across all three supported shapes Aug 9, 2026
Copilot AI requested a review from Badiboy August 9, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants