44import os
55
66import brawlstats
7+ from brawlstats .brawlapi .models import BattleLog , Club , Constants , Events , Leaderboard , PartialClub
78from dotenv import load_dotenv , find_dotenv
89
910load_dotenv (find_dotenv ('../.env' ))
@@ -19,7 +20,7 @@ async def setUp(self):
1920 self .player_tag = 'GGJVJLU2'
2021 self .club_tag = 'QCGV8PG'
2122 self .client = brawlstats .BrawlAPI (
22- TOKEN ,
23+ token = TOKEN ,
2324 is_async = True ,
2425 timeout = 30
2526 )
@@ -29,77 +30,85 @@ async def tearDown(self):
2930 await self .client .close ()
3031
3132 async def test_get_player (self ):
33+ """Test everything relating to the Player model"""
3234 player = await self .client .get_player (self .player_tag )
3335 self .assertEqual (player .tag , self .player_tag )
3436
37+ partialclub = await player .get_club (full = False )
38+ self .assertIsInstance (partialclub , PartialClub )
39+ full_club = await partialclub .get_full ()
40+ self .assertIsInstance (full_club , Club )
41+ club = await player .get_club ()
42+ self .assertIsInstance (club , Club )
43+
3544 async def test_get_club (self ):
3645 club = await self .client .get_club (self .club_tag )
3746 self .assertEqual (club .tag , self .club_tag )
3847
3948 async def test_get_leaderboard_player (self ):
4049 lb = await self .client .get_leaderboard ('players' )
41- self .assertTrue ( isinstance ( lb , brawlstats . brawlapi . Leaderboard ) )
50+ self .assertIsInstance ( lb , Leaderboard )
4251 region = await self .client .get_leaderboard ('players' , region = 'us' )
43- self .assertTrue ( isinstance ( region , brawlstats . brawlapi . Leaderboard ) )
52+ self .assertIsInstance ( region , Leaderboard )
4453
4554 async def test_get_leaderboard_club (self ):
4655 lb = await self .client .get_leaderboard ('clubs' )
47- self .assertTrue ( isinstance ( lb , brawlstats . brawlapi . Leaderboard ) )
56+ self .assertIsInstance ( lb , Leaderboard )
4857
4958 async def test_get_leaderboard_brawler (self ):
5059 lb = await self .client .get_leaderboard ('brawlers' , brawler = 'shelly' )
51- self .assertTrue ( isinstance ( lb , brawlstats . brawlapi . Leaderboard ) )
60+ self .assertIsInstance ( lb , Leaderboard )
5261
5362 async def test_get_events (self ):
5463 events = await self .client .get_events ()
55- self .assertTrue ( isinstance ( events . current , list ) )
64+ self .assertIsInstance ( events , Events )
5665
5766 async def test_get_constants (self ):
5867 default = await self .client .get_constants ()
59- self .assertTrue ( isinstance ( default , brawlstats . brawlapi . Constants ) )
68+ self .assertIsInstance ( default , Constants )
6069 maps = await self .client .get_constants ('maps' )
61- self .assertTrue ( isinstance ( maps , brawlstats . brawlapi . Constants ) )
70+ self .assertIsInstance ( maps , Constants )
6271
6372 async def request ():
6473 await self .get_constants (invalid_key )
6574 invalid_key = 'invalid'
66- self .assertAsyncRaises (KeyError , request )
75+ self .assertRaises (KeyError , request )
6776
6877 async def test_get_misc (self ):
6978 misc = await self .client .get_misc ()
7079 self .assertEqual (misc .server_date_year , datetime .date .today ().year )
7180
7281 async def test_club_search (self ):
7382 search = await self .client .search_club ('Cactus Bandits' )
74- self .assertTrue ( isinstance ( search , list ) )
83+ self .assertIsInstance ( search , list )
7584
7685 async def test_battle_logs (self ):
7786 logs = await self .client .get_battle_logs (self .player_tag )
78- self .assertTrue ( isinstance ( logs , brawlstats . brawlapi . BattleLog ) )
87+ self .assertIsInstance ( logs , BattleLog )
7988
8089 # Other
8190 async def test_invalid_tag (self ):
8291 async def request ():
8392 await self .client .get_player (invalid_tag )
8493 invalid_tag = 'P'
85- self .assertAsyncRaises (brawlstats .NotFoundError , request )
94+ self .assertRaises (brawlstats .NotFoundError , request )
8695 invalid_tag = 'AAA'
87- self .assertAsyncRaises (brawlstats .NotFoundError , request )
96+ self .assertRaises (brawlstats .NotFoundError , request )
8897 invalid_tag = '2PPPPPPP'
89- self .assertAsyncRaises (brawlstats .ServerError , request )
98+ self .assertRaises (brawlstats .ServerError , request )
9099
91100 async def test_invalid_lb (self ):
92101 async def request ():
93102 await self .client .get_leaderboard (invalid_type , invalid_limit )
94103 invalid_type = 'test'
95104 invalid_limit = 200
96- self .assertAsyncRaises (ValueError , request )
105+ self .assertRaises (ValueError , request )
97106 invalid_type = 'players'
98107 invalid_limit = 201
99- self .assertAsyncRaises (ValueError , request )
108+ self .assertRaises (ValueError , request )
100109 invalid_type = 'players'
101110 invalid_limit = - 5
102- self .assertAsyncRaises (ValueError , request )
111+ self .assertRaises (ValueError , request )
103112
104113
105114if __name__ == '__main__' :
0 commit comments