|
| 1 | +import sys |
| 2 | +from datetime import datetime, timezone |
| 3 | + |
| 4 | +def test_import(): |
| 5 | + sys.path.insert(0, ".") |
| 6 | + import scratchattach as sa |
| 7 | + |
| 8 | + studio = sa.get_studio(50809872) |
| 9 | + |
| 10 | + assert studio.title == "Sample studio" |
| 11 | + assert studio.description == "Sample text" |
| 12 | + assert studio.host_id == 58743127 |
| 13 | + assert studio.open_to_all is False |
| 14 | + assert studio.comments_allowed is False |
| 15 | + assert studio.image_url == 'https://cdn2.scratch.mit.edu/get_image/gallery/50809872_170x100.png' |
| 16 | + assert (datetime.fromisoformat(studio.created) == |
| 17 | + datetime(2025, 8, 26, 15, 3, 5, tzinfo=timezone.utc)) |
| 18 | + assert studio.follower_count > 0 |
| 19 | + assert 0 < studio.manager_count <= 2 |
| 20 | + assert studio.project_count == 2 |
| 21 | + |
| 22 | + # (un)follow |
| 23 | + |
| 24 | + comment = studio.comments()[0] |
| 25 | + assert comment.content == "Sample" |
| 26 | + assert comment.id == 302129887 |
| 27 | + assert comment.author_name == "faretek1" |
| 28 | + assert comment.replies()[0].content == "text" |
| 29 | + |
| 30 | + # comment replies, comment by id, post comment, delete comment, report comment, set thumb, reply comment |
| 31 | + projs = studio.projects() |
| 32 | + assert len(projs) == 2 |
| 33 | + assert projs[0].title == "Sample remix" |
| 34 | + assert projs[1].title == "Sample project #1" |
| 35 | + |
| 36 | + curator_names = [curator.name for curator in studio.managers()] |
| 37 | + assert "ScratchAttachV2" in curator_names |
| 38 | + |
| 39 | + assert not studio.curators() |
| 40 | + |
| 41 | + # invite/promote/remove curators transfer ownership / leave / add project / remove proj |
| 42 | + |
| 43 | + host = studio.host() |
| 44 | + assert host.name in ("faretek1", "ScratchAttachV2") |
| 45 | + |
| 46 | + # set fields, desc, title, open projects, close projects, turn on/off/toggle commenting |
| 47 | + assert studio.activity()[0].type == "addprojecttostudio" |
| 48 | + # accept invite/your role |
| 49 | + |
| 50 | + # If we run out of 'add everything!' studios, clearly something has gone wrong. |
| 51 | + assert sa.search_studios(query="add everything!") |
| 52 | + assert sa.explore_studios(query="*") |
0 commit comments