Skip to content

Commit a8ea40c

Browse files
committed
test: studio
1 parent 099ea1d commit a8ea40c

3 files changed

Lines changed: 56 additions & 4 deletions

File tree

scratchattach/site/studio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def projects(self, limit=40, offset=0):
306306
f"https://api.scratch.mit.edu/studios/{self.id}/projects", limit=limit, offset=offset)
307307
return commons.parse_object_list(response, project.Project, self._session)
308308

309-
def curators(self, limit=40, offset=0):
309+
def curators(self, limit=40, offset=0) -> list[user.User]:
310310
"""
311311
Gets the studio curators.
312312
@@ -443,7 +443,7 @@ def managers(self, limit=40, offset=0):
443443
f"https://api.scratch.mit.edu/studios/{self.id}/managers", limit=limit, offset=offset)
444444
return commons.parse_object_list(response, user.User, self._session, "username")
445445

446-
def host(self):
446+
def host(self) -> user.User:
447447
"""
448448
Gets the studio host.
449449

tests/test_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import sys
22
def test_import():
3-
sys.path.insert(0, ".")
4-
import scratchattach
3+
sys.path.insert(0, ".")
4+
import scratchattach as sa

tests/test_studio.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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

Comments
 (0)