@@ -63,6 +63,17 @@ def when_I_assign_comment_eq_comments_add_comment_with_author_and_initials(conte
6363 context .comment = context .comments .add_comment (author = "John Doe" , initials = "JD" )
6464
6565
66+ @when ('I assign comment = document.add_comment(runs, "A comment", "John Doe", "JD")' )
67+ def when_I_assign_comment_eq_document_add_comment (context : Context ):
68+ runs = list (context .document .paragraphs [0 ].runs )
69+ context .comment = context .document .add_comment (
70+ runs = runs ,
71+ text = "A comment" ,
72+ author = "John Doe" ,
73+ initials = "JD" ,
74+ )
75+
76+
6677@when ('I assign "{initials}" to comment.initials' )
6778def when_I_assign_initials (context : Context , initials : str ):
6879 context .comment .initials = initials
@@ -98,10 +109,9 @@ def when_I_call_comments_get_2(context: Context):
98109# then =====================================================
99110
100111
101- @then ("comment.author is the author of the comment" )
102- def then_comment_author_is_the_author_of_the_comment (context : Context ):
103- actual = context .comment .author
104- assert actual == "Steve Canny" , f"expected author 'Steve Canny', got '{ actual } '"
112+ @then ("comment is a Comment object" )
113+ def then_comment_is_a_Comment_object (context : Context ):
114+ assert type (context .comment ) is Comment
105115
106116
107117@then ('comment.author == "{author}"' )
@@ -110,6 +120,12 @@ def then_comment_author_eq_author(context: Context, author: str):
110120 assert actual == author , f"expected author '{ author } ', got '{ actual } '"
111121
112122
123+ @then ("comment.author is the author of the comment" )
124+ def then_comment_author_is_the_author_of_the_comment (context : Context ):
125+ actual = context .comment .author
126+ assert actual == "Steve Canny" , f"expected author 'Steve Canny', got '{ actual } '"
127+
128+
113129@then ("comment.comment_id == 0" )
114130def then_comment_id_is_0 (context : Context ):
115131 assert context .comment .comment_id == 0
@@ -146,6 +162,13 @@ def then_comment_paragraphs_idx_style_name_eq_style(context: Context, idx: str,
146162 assert actual == expected , f"expected style name '{ expected } ', got '{ actual } '"
147163
148164
165+ @then ('comment.text == "{text}"' )
166+ def then_comment_text_eq_text (context : Context , text : str ):
167+ actual = context .comment .text
168+ expected = text
169+ assert actual == expected , f"expected text '{ expected } ', got '{ actual } '"
170+
171+
149172@then ("comment.timestamp is the date and time the comment was authored" )
150173def then_comment_timestamp_is_the_date_and_time_the_comment_was_authored (context : Context ):
151174 assert context .comment .timestamp == dt .datetime (2025 , 6 , 7 , 11 , 20 , 0 , tzinfo = dt .timezone .utc )
0 commit comments