| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,14 +47,12 @@ Feature: Comment mutations | |||
| 47 | 47 | Then run.iter_inner_content() yields a single Picture drawing | |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | - @wip | ||
| 51 | 50 | Scenario: update Comment.author | |
| 52 | 51 | Given a Comment object | |
| 53 | 52 | When I assign "Jane Smith" to comment.author | |
| 54 | 53 | Then comment.author == "Jane Smith" | |
| 55 | 54 | ||
| 56 | 55 | ||
| 57 | - @wip | ||
| 58 | 56 | Scenario: update Comment.initials | |
| 59 | 57 | Given a Comment object | |
| 60 | 58 | When I assign "JS" to comment.initials | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,9 +116,16 @@ def add_paragraph(self, text: str = "", style: str | ParagraphStyle | None = Non | |||
| 116 | 116 | ||
| 117 | 117 | @property | |
| 118 | 118 | def author(self) -> str: | |
| 119 | - """The recorded author of this comment.""" | ||
| 119 | + """Read/write. The recorded author of this comment. | ||
| 120 | + | ||
| 121 | + This field is required but can be set to the empty string. | ||
| 122 | + """ | ||
| 120 | 123 | return self._comment_elm.author | |
| 121 | 124 | ||
| 125 | + @author.setter | ||
| 126 | + def author(self, value: str): | ||
| 127 | + self._comment_elm.author = value | ||
| 128 | + | ||
| 122 | 129 | @property | |
| 123 | 130 | def comment_id(self) -> int: | |
| 124 | 131 | """The unique identifier of this comment.""" | |
@@ -133,6 +140,10 @@ def initials(self) -> str | None: | |||
| 133 | 140 | """ | |
| 134 | 141 | return self._comment_elm.initials | |
| 135 | 142 | ||
| 143 | + @initials.setter | ||
| 144 | + def initials(self, value: str | None): | ||
| 145 | + self._comment_elm.initials = value | ||
| 146 | + | ||
| 136 | 147 | @property | |
| 137 | 148 | def timestamp(self) -> dt.datetime | None: | |
| 138 | 149 | """The date and time this comment was authored. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -328,7 +328,7 @@ def __init__(self, parent: t.ProvidesXmlPart): | |||
| 328 | 328 | self._parent = parent | |
| 329 | 329 | ||
| 330 | 330 | @property | |
| 331 | - def part(self): | ||
| 331 | + def part(self) -> XmlPart: | ||
| 332 | 332 | """The package part containing this object.""" | |
| 333 | 333 | return self._parent.part | |
| 334 | 334 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -153,6 +153,14 @@ def and_it_can_add_text_to_the_comment_when_adding_it(self, comments: Comments, | |||
| 153 | 153 | assert [p.text for p in comment.paragraphs] == ["para 1", "", "para 2"] | |
| 154 | 154 | assert all(p._p.style == "CommentText" for p in comment.paragraphs) | |
| 155 | 155 | ||
| 156 | + def and_it_sets_the_author_and_their_initials_when_adding_a_comment_when_provided( | ||
| 157 | + self, comments: Comments, package_: Mock | ||
| 158 | + ): | ||
| 159 | + comment = comments.add_comment(author="Steve Canny", initials="SJC") | ||
| 160 | + | ||
| 161 | + assert comment.author == "Steve Canny" | ||
| 162 | + assert comment.initials == "SJC" | ||
| 163 | + | ||
| 156 | 164 | # -- fixtures -------------------------------------------------------------------------------- | |
| 157 | 165 | ||
| 158 | 166 | @pytest.fixture | |
@@ -213,6 +221,33 @@ def it_provides_access_to_the_paragraphs_it_contains(self, comments_part_: Mock) | |||
| 213 | 221 | assert len(paragraphs) == 2 | |
| 214 | 222 | assert [para.text for para in paragraphs] == ["First para", "Second para"] | |
| 215 | 223 | ||
| 224 | + def it_can_update_the_comment_author(self, comments_part_: Mock): | ||
| 225 | + comment_elm = cast(CT_Comment, element("w:comment{w:id=42,w:author=Old Author}")) | ||
| 226 | + comment = Comment(comment_elm, comments_part_) | ||
| 227 | + | ||
| 228 | + comment.author = "New Author" | ||
| 229 | + | ||
| 230 | + assert comment.author == "New Author" | ||
| 231 | + | ||
| 232 | + @pytest.mark.parametrize( | ||
| 233 | + "initials", | ||
| 234 | + [ | ||
| 235 | + # -- valid initials -- | ||
| 236 | + "XYZ", | ||
| 237 | + # -- empty string is valid | ||
| 238 | + "", | ||
| 239 | + # -- None is valid, removes existing initials | ||
| 240 | + None, | ||
| 241 | + ], | ||
| 242 | + ) | ||
| 243 | + def it_can_update_the_comment_initials(self, initials: str | None, comments_part_: Mock): | ||
| 244 | + comment_elm = cast(CT_Comment, element("w:comment{w:id=42,w:initials=ABC}")) | ||
| 245 | + comment = Comment(comment_elm, comments_part_) | ||
| 246 | + | ||
| 247 | + comment.initials = initials | ||
| 248 | + | ||
| 249 | + assert comment.initials == initials | ||
| 250 | + | ||
| 216 | 251 | # -- fixtures -------------------------------------------------------------------------------- | |
| 217 | 252 | ||
| 218 | 253 | @pytest.fixture | |
| Back | FazBrowse Home | New Git URL |
0 commit comments