Skip to content

Commit eefcd44

Browse files
committed
test: project
1 parent 86a046f commit eefcd44

3 files changed

Lines changed: 58 additions & 7 deletions

File tree

scratchattach/site/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def embed_url(self):
113113
"""
114114
return f"{self.url}/embed"
115115

116-
def remixes(self, *, limit=40, offset=0):
116+
def remixes(self, *, limit=40, offset=0) -> list[Project]:
117117
"""
118118
Returns:
119119
list<scratchattach.project.Project>: A list containing the remixes of the project, each project is represented by a Project object.
@@ -346,7 +346,7 @@ def creator_agent(self):
346346
"""
347347
return self.raw_json()["meta"]["agent"]
348348

349-
def author(self):
349+
def author(self) -> user.User:
350350
"""
351351
Returns:
352352
scratchattach.user.User: An object representing the Scratch user who created this project.

tests/test_editor_project.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from scratchattach import editor
2+
3+
def test_1():
4+
project = editor.Project.from_id(1209355136)

tests/test_project.py

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
11
def test_get():
2-
import scratchattach as sa
3-
project = sa.get_project(104)
4-
assert project
5-
assert project.title == "Weekend"
6-
assert project.author_name == "andresmh"
2+
import scratchattach as sa
3+
project = sa.get_project(1209355136)
4+
5+
assert project
6+
assert project.title == "Sample project #1"
7+
assert project.author_name == "ScratchAttachV2"
8+
assert project.embed_url == "https://scratch.mit.edu/projects/1209355136/embed"
9+
assert project.is_shared()
10+
# create_remix
11+
# load_description
12+
# download
13+
# get_json
14+
# body
15+
# raw_json
16+
# raw_json_or_empty
17+
# creator_agent
18+
assert project.author().id == 147905216
19+
# studios
20+
comment = project.comments()[0] # TODO: move this to a separate comment tester
21+
# comment_by_id
22+
#comment_replies
23+
# comment by id
24+
# (un)love
25+
# (un)favorite
26+
# pos_view
27+
# set_fields
28+
# turn on/off/toggle commenting
29+
# (un)share
30+
# set thumb
31+
# delete comment
32+
# report comment
33+
# post/reply comment
34+
# set body/json/upload json from
35+
# set title/instruction/notes
36+
# visibility
37+
38+
39+
assert comment.id == 489648029
40+
41+
remix = project.remixes()[0]
42+
assert remix.id == 1209582809
43+
assert remix.title == "Sample remix"
44+
assert remix.author_name == "ScratchAttachV2"
45+
assert remix.embed_url == "https://scratch.mit.edu/projects/1209582809/embed"
46+
47+
assert sa.get_project(414601586).moderation_status() == "notsafe"
48+
assert sa.get_project(1207314193).moderation_status() == "safe"
49+
assert sa.get_project(1233).moderation_status() == "notreviewed" # if this becomes reviewed, please update this
50+
# ^^ also this project is an infinite remix loop!
51+
52+
assert sa.explore_projects()
53+
assert sa.search_projects(query="scratchattach")

0 commit comments

Comments
 (0)