Skip to content

Commit 2db14c9

Browse files
committed
feat: studio dataclass
For #413 and #408
1 parent bcae755 commit 2db14c9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

scratchattach/site/studio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing_extensions import Optional
1010

1111
from . import user, comment, project, activity, session
12-
from scratchattach.site.typed_dicts import StudioDict
12+
from scratchattach.site.typed_dicts import StudioDict, StudioRoleDict
1313
from ._base import BaseSiteComponent
1414
from scratchattach.utils import exceptions, commons
1515
from scratchattach.utils.commons import api_iterative, headers
@@ -615,7 +615,7 @@ def accept_invite(self):
615615
timeout=10,
616616
).json()
617617

618-
def your_role(self):
618+
def your_role(self) -> StudioRoleDict:
619619
"""
620620
Returns a dict with information about your role in the studio (whether you're following, curating, managing it or are invited)
621621
"""

scratchattach/site/typed_dicts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,9 @@ class StudioDict(TypedDict):
118118
image: str
119119
history: StudioHistoryDict
120120
stats: NotRequired[StudioStatsDict]
121+
122+
class StudioRoleDict(TypedDict):
123+
manager: bool
124+
curator: bool
125+
invited: bool
126+
following: bool

tests/test_studio.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def test_studio():
3939
assert projs[0].title == "Sample remix"
4040
assert projs[1].title == "Sample project #1"
4141

42+
role = studio.your_role()
43+
assert role["manager"]
44+
assert role["following"]
45+
4246
curator_names = [curator.name for curator in studio.managers()]
4347
assert "ScratchAttachV2" in curator_names
4448

@@ -57,5 +61,6 @@ def test_studio():
5761
assert sa.search_studios(query="add everything!")
5862
assert sa.explore_studios(query="*")
5963

64+
6065
if __name__ == '__main__':
6166
test_studio()

0 commit comments

Comments
 (0)