()
| 5 | |
| 6 | |
| 7 | def test_comment(): |
| 8 | if not util.credentials_available(): |
| 9 | warnings.warn("Skipped test_comment because there were no credentials available.") |
| 10 | return |
| 11 | sess = util.session() |
| 12 | |
| 13 | user = sess.connect_linked_user() |
| 14 | proj = sess.connect_project(1108326850) |
| 15 | studio = sess.connect_studio(50809872) |
| 16 | |
| 17 | comment = user.comments()[0] |
| 18 | |
| 19 | assert comment.id == "387076703" |
| 20 | assert comment.source == sa.CommentSource.USER_PROFILE |
| 21 | assert comment.source_id == "ScratchAttachV2" |
| 22 | assert comment.parent_id is None |
| 23 | assert comment.content == "Sample comment" |
| 24 | assert datetime.fromisoformat(comment.datetime_created) - datetime(2025, 8, 25, tzinfo=timezone.utc) < timedelta(days=1) |
| 25 | assert comment.reply_count == 0 |
| 26 | assert comment.text == "Sample comment" |
| 27 | |
| 28 | comment = proj.comments(limit=1)[0] |
| 29 | |
| 30 | assert comment.id == 494890468 |
| 31 | assert comment.source == sa.CommentSource.PROJECT |
| 32 | assert comment.source_id == 1108326850 |
| 33 | assert comment.parent_id is None |
| 34 | assert comment.content == ("<&;'!\nnewline\ntesting escaping") |
| 35 | assert datetime.fromisoformat(comment.datetime_created) - datetime(2025, 9, 20, tzinfo=timezone.utc) < timedelta(days=1) |
| 36 | assert comment.reply_count == 0 |
| 37 | assert comment.text == ("<&;'!\nnewline\ntesting escaping") |
| 38 | |
| 39 | comment = studio.comments(limit=1)[0] |
| 40 | |
| 41 | assert comment.id == 302129887 |
| 42 | assert comment.source == sa.CommentSource.STUDIO |
| 43 | assert comment.source_id == 50809872 |
| 44 | assert comment.parent_id is None |
| 45 | assert comment.content == "Sample" |
| 46 | assert datetime.fromisoformat(comment.datetime_created) - datetime(2025, 8, 26, tzinfo=timezone.utc) < timedelta(days=1) |
| 47 | assert comment.reply_count == 1 |
| 48 | assert not comment.written_by_scratchteam |
| 49 | assert comment.text == "Sample" |
| 50 | |
| 51 | comment = comment.replies(limit=1)[0] |
| 52 | |
| 53 | assert comment.id == 302129910 |
| 54 | assert comment.source == sa.CommentSource.STUDIO |
| 55 | assert comment.source_id == 50809872 |
| 56 | assert comment.parent_id == 302129887 |
| 57 | assert comment.commentee_id == 58743127 |
| 58 | assert comment.content == "text" |
| 59 | assert datetime.fromisoformat(comment.datetime_created) - datetime(2025, 8, 26, tzinfo=timezone.utc) < timedelta(days=1) |
| 60 | assert comment.reply_count == 0 |
| 61 | assert not comment.written_by_scratchteam |
| 62 | assert comment.text == "text" |
| 63 | |
| 64 |
no test coverage detected