Skip to content

Commit

Permalink
feat: return UserRelation from get_own_friends (#254)
Browse files Browse the repository at this point in the history
* feat: return `UserRelation` from `get_own_friends`

* chore: update tests

* fix: wrong name for header in test generator
  • Loading branch information
NiceAesth authored Nov 2, 2024
1 parent 5a543d9 commit 81367bf
Show file tree
Hide file tree
Showing 81 changed files with 86 additions and 82 deletions.
10 changes: 6 additions & 4 deletions aiosu/v2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from ..models import User
from ..models import UserBeatmapType
from ..models import UserQueryType
from ..models import UserRelation
from ..models import WikiPage
from .repository import BaseTokenRepository
from .repository import SimpleTokenRepository
Expand Down Expand Up @@ -760,17 +761,18 @@ async def get_me(self, **kwargs: Any) -> User:
@check_token
@requires_scope(Scopes.FRIENDS_READ)
@requires_scope(Scopes.IDENTIFY | Scopes.DELEGATE, any_scope=True)
async def get_own_friends(self) -> list[User]:
async def get_own_friends(self) -> list[UserRelation]:
r"""Gets the token owner's friend list
:raises APIException: Contains status code and error message
:raises RefreshTokenExpiredError: If the client refresh token has expired
:return: List of friends
:rtype: list[aiosu.models.user.User]
:rtype: list[aiosu.models.user.UserRelation]
"""
url = f"{self.base_url}/api/v2/friends"
json = await self._request("GET", url)
return from_list(User.model_validate, json)
headers = {"x-api-version": "20241022"}
json = await self._request("GET", url, headers=headers)
return from_list(UserRelation.model_validate, json)

@prepare_token
@check_token
Expand Down
2 changes: 1 addition & 1 deletion tests/data/v1/get_beatmap_200.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/data/v1/get_beatmap_scores_200.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/data/v1/get_user_200.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"user_id":"2","username":"peppy","join_date":"2007-08-28 03:09:12","count300":"679157","count100":"122579","count50":"26895","playcount":"7692","ranked_score":"445065750","total_score":"1987865681","pp_rank":"770742","level":"67.059","pp_raw":"863.04","accuracy":"97.12474822998047","count_rank_ss":"15","count_rank_ssh":"0","count_rank_s":"75","count_rank_sh":"0","count_rank_a":"121","country":"AU","total_seconds_played":"738717","pp_country_rank":"17073","events":[]}]
[{"user_id":"2","username":"peppy","join_date":"2007-08-28 03:09:12","count300":"680450","count100":"122974","count50":"27025","playcount":"7703","ranked_score":"447965404","total_score":"1992168311","pp_rank":"817624","level":"67.1066","pp_raw":"1126.82","accuracy":"96.57911682128906","count_rank_ss":"15","count_rank_ssh":"0","count_rank_s":"75","count_rank_sh":"0","count_rank_a":"122","country":"AU","total_seconds_played":"739655","pp_country_rank":"20408","events":[]}]
2 changes: 1 addition & 1 deletion tests/data/v1/get_user_bests_200.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"beatmap_id":"22423","score_id":"1720541511","score":"2669868","maxcombo":"450","count50":"0","count100":"0","count300":"254","countmiss":"0","countkatu":"0","countgeki":"38","perfect":"1","enabled_mods":"16416","user_id":"2","date":"2014-03-25 03:58:04","rank":"X","pp":"71.8627","replay_available":"0"},{"beatmap_id":"258467","score_id":"1759225512","score":"2063452","maxcombo":"349","count50":"0","count100":"0","count300":"239","countmiss":"0","countkatu":"0","countgeki":"61","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-06-24 13:49:54","rank":"X","pp":"56.1629","replay_available":"0"},{"beatmap_id":"266885","score_id":"1717638933","score":"8235244","maxcombo":"712","count50":"0","count100":"11","count300":"470","countmiss":"0","countkatu":"11","countgeki":"85","perfect":"0","enabled_mods":"0","user_id":"2","date":"2014-03-18 10:25:25","rank":"S","pp":"54.3976","replay_available":"0"},{"beatmap_id":"119488","score_id":"1772068798","score":"4381728","maxcombo":"589","count50":"0","count100":"4","count300":"298","countmiss":"0","countkatu":"3","countgeki":"77","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-07-24 08:29:59","rank":"S","pp":"51.7284","replay_available":"0"},{"beatmap_id":"197337","score_id":"1771224377","score":"2111674","maxcombo":"388","count50":"0","count100":"16","count300":"221","countmiss":"3","countkatu":"11","countgeki":"35","perfect":"0","enabled_mods":"0","user_id":"2","date":"2014-07-22 09:18:53","rank":"A","pp":"50.5219","replay_available":"0"},{"beatmap_id":"8708","score_id":"5267449","score":"2954806","maxcombo":"447","count50":"0","count100":"1","count300":"277","countmiss":"0","countkatu":"1","countgeki":"41","perfect":"1","enabled_mods":"0","user_id":"2","date":"2008-10-17 02:42:22","rank":"S","pp":"46.0602","replay_available":"0"},{"beatmap_id":"417911","score_id":"1767877047","score":"1995646","maxcombo":"359","count50":"1","count100":"3","count300":"222","countmiss":"0","countkatu":"3","countgeki":"53","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-07-14 12:22:05","rank":"S","pp":"41.7577","replay_available":"0"},{"beatmap_id":"9892","score_id":"585223","score":"2126186","maxcombo":"305","count50":"0","count100":"19","count300":"260","countmiss":"0","countkatu":"12","countgeki":"63","perfect":"1","enabled_mods":"0","user_id":"2","date":"2008-04-29 23:18:53","rank":"S","pp":"41.236","replay_available":"0"},{"beatmap_id":"80","score_id":"1720542498","score":"3312912","maxcombo":"417","count50":"2","count100":"13","count300":"324","countmiss":"2","countkatu":"6","countgeki":"40","perfect":"0","enabled_mods":"0","user_id":"2","date":"2014-03-25 04:03:19","rank":"A","pp":"41.1208","replay_available":"0"},{"beatmap_id":"19538","score_id":"5010350","score":"1009962","maxcombo":"236","count50":"0","count100":"14","count300":"172","countmiss":"1","countkatu":"8","countgeki":"33","perfect":"0","enabled_mods":"0","user_id":"2","date":"2008-10-10 17:10:54","rank":"A","pp":"40.4416","replay_available":"0"}]
[{"beatmap_id":"22423","score_id":"1720541511","score":"2669868","maxcombo":"450","count50":"0","count100":"0","count300":"254","countmiss":"0","countkatu":"0","countgeki":"38","perfect":"1","enabled_mods":"16416","user_id":"2","date":"2014-03-25 03:58:04","rank":"X","pp":"70.5239","replay_available":"0"},{"beatmap_id":"258467","score_id":"1759225512","score":"2063452","maxcombo":"349","count50":"0","count100":"0","count300":"239","countmiss":"0","countkatu":"0","countgeki":"61","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-06-24 13:49:54","rank":"X","pp":"57.6853","replay_available":"0"},{"beatmap_id":"266885","score_id":"1717638933","score":"8235244","maxcombo":"712","count50":"0","count100":"11","count300":"470","countmiss":"0","countkatu":"11","countgeki":"85","perfect":"0","enabled_mods":"0","user_id":"2","date":"2014-03-18 10:25:25","rank":"S","pp":"53.9028","replay_available":"0"},{"beatmap_id":"119488","score_id":"1772068798","score":"4381728","maxcombo":"589","count50":"0","count100":"4","count300":"298","countmiss":"0","countkatu":"3","countgeki":"77","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-07-24 08:29:59","rank":"S","pp":"49.5682","replay_available":"0"},{"beatmap_id":"8708","score_id":"5267449","score":"2954806","maxcombo":"447","count50":"0","count100":"1","count300":"277","countmiss":"0","countkatu":"1","countgeki":"41","perfect":"1","enabled_mods":"0","user_id":"2","date":"2008-10-17 02:42:22","rank":"S","pp":"44.2224","replay_available":"0"},{"beatmap_id":"197337","score_id":"1771224377","score":"2111674","maxcombo":"388","count50":"0","count100":"16","count300":"221","countmiss":"3","countkatu":"11","countgeki":"35","perfect":"0","enabled_mods":"0","user_id":"2","date":"2014-07-22 09:18:53","rank":"A","pp":"43.6864","replay_available":"0"},{"beatmap_id":"417911","score_id":"1767877047","score":"1995646","maxcombo":"359","count50":"1","count100":"3","count300":"222","countmiss":"0","countkatu":"3","countgeki":"53","perfect":"1","enabled_mods":"0","user_id":"2","date":"2014-07-14 12:22:05","rank":"S","pp":"39.8375","replay_available":"0"},{"beatmap_id":"9892","score_id":"585223","score":"2126186","maxcombo":"305","count50":"0","count100":"19","count300":"260","countmiss":"0","countkatu":"12","countgeki":"63","perfect":"1","enabled_mods":"0","user_id":"2","date":"2008-04-29 23:18:53","rank":"S","pp":"38.0343","replay_available":"0"},{"beatmap_id":"26394","score_id":"11851860","score":"8085024","maxcombo":"747","count50":"0","count100":"4","count300":"450","countmiss":"0","countkatu":"4","countgeki":"53","perfect":"1","enabled_mods":"0","user_id":"2","date":"2009-02-26 03:52:55","rank":"S","pp":"37.5762","replay_available":"0"},{"beatmap_id":"17925","score_id":"3107654","score":"2356444","maxcombo":"381","count50":"0","count100":"3","count300":"290","countmiss":"0","countkatu":"3","countgeki":"68","perfect":"0","enabled_mods":"0","user_id":"2","date":"2008-08-30 02:22:35","rank":"S","pp":"36.1991","replay_available":"0"}]
2 changes: 1 addition & 1 deletion tests/data/v1/get_user_recents_200.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"beatmap_id":"3753479","score":"95972","maxcombo":"41","count50":"0","count100":"1","count300":"68","countmiss":"3","countkatu":"0","countgeki":"8","perfect":"0","enabled_mods":"72","user_id":"11367222","date":"2024-02-29 07:31:17","rank":"F","score_id":null},{"beatmap_id":"3753479","score":"263302","maxcombo":"95","count50":"0","count100":"2","count300":"117","countmiss":"12","countkatu":"2","countgeki":"21","perfect":"0","enabled_mods":"72","user_id":"11367222","date":"2024-02-29 07:31:05","rank":"F","score_id":null},{"beatmap_id":"3748607","score":"571980","maxcombo":"150","count50":"0","count100":"1","count300":"111","countmiss":"4","countkatu":"1","countgeki":"51","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:29:48","rank":"F","score_id":null},{"beatmap_id":"3748607","score":"738040","maxcombo":"162","count50":"0","count100":"2","count300":"162","countmiss":"3","countkatu":"2","countgeki":"76","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:29:18","rank":"F","score_id":null},{"beatmap_id":"2223077","score":"40422","maxcombo":"29","count50":"0","count100":"0","count300":"62","countmiss":"33","countkatu":"0","countgeki":"15","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:28:26","rank":"F","score_id":null},{"beatmap_id":"2223077","score":"104338","maxcombo":"48","count50":"0","count100":"5","count300":"114","countmiss":"18","countkatu":"3","countgeki":"28","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:28:09","rank":"F","score_id":null},{"beatmap_id":"2223077","score":"297502","maxcombo":"100","count50":"0","count100":"15","count300":"180","countmiss":"36","countkatu":"12","countgeki":"47","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:27:42","rank":"F","score_id":null},{"beatmap_id":"2223077","score":"25518","maxcombo":"29","count50":"0","count100":"1","count300":"35","countmiss":"8","countkatu":"1","countgeki":"9","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:27:01","rank":"F","score_id":null},{"beatmap_id":"1693496","score":"206112","maxcombo":"53","count50":"0","count100":"7","count300":"220","countmiss":"16","countkatu":"3","countgeki":"7","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:25:03","rank":"A","score_id":null},{"beatmap_id":"2468903","score":"5895898","maxcombo":"547","count50":"3","count100":"26","count300":"464","countmiss":"3","countkatu":"15","countgeki":"90","perfect":"0","enabled_mods":"0","user_id":"11367222","date":"2024-02-29 07:23:17","rank":"A","score_id":null}]
[{"beatmap_id":"3852942","score":"3316818","maxcombo":"350","count50":"0","count100":"17","count300":"330","countmiss":"17","countkatu":"7","countgeki":"49","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:58:52","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"65015","maxcombo":"52","count50":"4","count100":"6","count300":"33","countmiss":"5","countkatu":"1","countgeki":"2","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:57:47","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"170323","maxcombo":"69","count50":"1","count100":"4","count300":"81","countmiss":"9","countkatu":"0","countgeki":"8","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:57:39","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"71442","maxcombo":"53","count50":"0","count100":"7","count300":"36","countmiss":"6","countkatu":"2","countgeki":"2","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:57:28","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"320541","maxcombo":"127","count50":"1","count100":"9","count300":"87","countmiss":"6","countkatu":"3","countgeki":"6","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:57:21","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"573688","maxcombo":"149","count50":"3","count100":"16","count300":"148","countmiss":"4","countkatu":"8","countgeki":"10","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:57:09","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"2941813","maxcombo":"333","count50":"6","count100":"22","count300":"385","countmiss":"17","countkatu":"11","countgeki":"35","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:56:51","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"71290","maxcombo":"55","count50":"0","count100":"6","count300":"36","countmiss":"10","countkatu":"1","countgeki":"3","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:56:06","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"63526","maxcombo":"53","count50":"0","count100":"9","count300":"32","countmiss":"9","countkatu":"2","countgeki":"2","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:55:59","rank":"F","score_id":null},{"beatmap_id":"4628575","score":"52086","maxcombo":"49","count50":"0","count100":"5","count300":"29","countmiss":"11","countkatu":"0","countgeki":"3","perfect":"0","enabled_mods":"64","user_id":"11367222","date":"2024-11-02 11:55:45","rank":"F","score_id":null}]
2 changes: 1 addition & 1 deletion tests/data/v2/difficulty_attributes_mania.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"attributes":{"star_rating":5.481929779052734,"max_combo":3994,"great_hit_window":38}}
{"attributes":{"star_rating":5.481880187988281,"max_combo":3994,"great_hit_window":38}}
2 changes: 1 addition & 1 deletion tests/data/v2/difficulty_attributes_osu.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"attributes":{"star_rating":8.22562026977539,"max_combo":1337,"aim_difficulty":4.598330020904541,"speed_difficulty":2.80253005027771,"speed_note_count":423.4209899902344,"flashlight_difficulty":0,"slider_factor":0.7838699817657471,"approach_rate":9.699999809265137,"overall_difficulty":9}}
{"attributes":{"star_rating":7.751629829406738,"max_combo":2900,"aim_difficulty":3.740999937057495,"speed_difficulty":3.656670093536377,"speed_note_count":1194.47998046875,"flashlight_difficulty":0,"slider_factor":0.9997360110282898,"approach_rate":9.800000190734863,"overall_difficulty":9.800000190734863}}
2 changes: 1 addition & 1 deletion tests/data/v2/difficulty_attributes_taiko.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"attributes":{"star_rating":7.204160213470459,"max_combo":877,"stamina_difficulty":0,"rhythm_difficulty":0,"colour_difficulty":0,"peak_difficulty":0,"great_hit_window":26}}
{"attributes":{"star_rating":6.660490036010742,"max_combo":877,"stamina_difficulty":0,"rhythm_difficulty":0,"colour_difficulty":0,"peak_difficulty":0,"great_hit_window":26}}
Loading

0 comments on commit 81367bf

Please sign in to comment.