Skip to content

Commit

Permalink
Type conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
ManicJamie committed Sep 25, 2024
1 parent 3d4c74b commit 87c6e0f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
6 changes: 6 additions & 0 deletions src/speedruncompy/datatypes/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,12 @@ class Conversation(Datatype):
lastMessageDate: int
readDate: int

class ConversationLightweight(Datatype):
id: str
participantUserIds: list[str] # TODO: May always be empty?
lastMessageId: str
lastMessageDate: int

class ConversationParticipant(Datatype):
conversationId: str
userId: str
Expand Down
11 changes: 6 additions & 5 deletions src/speedruncompy/datatypes/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class r_GetStaticData(Datatype):
platformList: list[Platform]
regionList: list[Region]
socialNetworkList: list[SocialNetwork]
supporterPlanList: OptField[list[Any]] # Unknown type
supporterPlanList: OptField[list[Any] | None] # Unknown type

class r_GetGameData(Datatype):
game: Game
Expand Down Expand Up @@ -266,6 +266,7 @@ class r_GetUserComments(Datatype):
runList: list[Run]
threadList: list[Thread]
userList: list[User]
pagination: Pagination

class r_GetUserPopoverData(Datatype):
user: User
Expand Down Expand Up @@ -442,7 +443,7 @@ class r_PutUserSettings(Datatype):
class r_GetUserApiKey(Datatype):
apiKey: str

class r_GetUserGameBoostData(Datatype): # TODO: check which ones are optional
class r_GetUserGameBoostData(Datatype):
boostAvailableTokens: int
boostDistinctGamesCount: int
boostDistinctUsersCount: int
Expand All @@ -452,15 +453,15 @@ class r_GetUserGameBoostData(Datatype): # TODO: check which ones are optional
boostNextTokenAmount: int
boostNextTokenDate: int
boostReceivedCount: int
boostGameList: list[GameBoost]
gameBoostList: list[GameBoost]
gameList: list[Game]
isBoosted: bool
userList: list[User]

class r_GetUserDataExport(Datatype):
articleList: list[Article]
commentList: list[Comment]
conversationList: list[Conversation]
conversationList: list[ConversationLightweight]
gameFollowerList: list[GameFollower]
guideList: list[Guide]
likeList: list[Like]
Expand All @@ -474,7 +475,7 @@ class r_GetUserDataExport(Datatype):
user: User
userFollowerList: list[UserFollower]
userSettings: UserSettings
UserSocialConnectionList: list[UserSocialConnection]
userSocialConnectionList: list[UserSocialConnection]

class r_PutUserUpdateEmail(Datatype):
emailChanged: bool
Expand Down
16 changes: 0 additions & 16 deletions test/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,6 @@ class TestDT(Datatype):
test: OptField[int]

TestDT({}) # Test construction does not error

def test_EnumMissingValue(self):
class TestEnum(enums.StrEnum):
... # No values

with pytest.raises(IncompleteEnum):
TestEnum("test")

def test_EnumMissingValue_loose(self, caplog: pytest.LogCaptureFixture, loose_type_conformance):
class TestEnum(enums.StrEnum):
... # No values

with caplog.at_level(logging.WARNING):
TestEnum("test")

assert "Enum TestEnum missing value test. Adding missing value..." in caplog.text

@pytest.mark.skipif(SKIP_HEAVY_TESTS, reason="SKIP_HEAVY_TESTS == True")
class TestDatatypes_Integration_Heavy():
Expand Down
7 changes: 1 addition & 6 deletions test/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,6 @@ def test_GetGameList(self):
log_result(result)
check_datatype_coverage(result)

def test_GetHomeSummary(self):
result = GetHomeSummary().perform()
log_result(result)
check_datatype_coverage(result)

def test_GetHomeSummary(self):
result = GetHomeSummary(_api=self.api).perform()
log_result(result)
Expand Down Expand Up @@ -907,4 +902,4 @@ def test_PutUserUpdateName(self):
def test_GetSeriesSettings(self):
result = GetSeriesSettings("").perform()
log_result(result)
check_datatype_coverage(result)
check_datatype_coverage(result)

0 comments on commit 87c6e0f

Please sign in to comment.