forked from Top-gg-Community/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
83 lines (53 loc) · 2.08 KB
/
test.py
File metadata and controls
83 lines (53 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import topgg
from sys import stdout
import asyncio
import os
INDENTATION = 2
def is_local(data: object) -> bool:
return getattr(data, '__module__', '').startswith('topgg')
def _test_attributes(obj: object, indent_level: int) -> None:
for name in getattr(obj.__class__, '__slots__', ()):
stdout.write(f'{" " * indent_level}{obj.__class__.__name__}.{name}')
data = getattr(obj, name)
if isinstance(data, list) and data:
stdout.write('[0] -> ')
for i, each in enumerate(data):
if i > 0:
stdout.write(
f'{" " * indent_level}{obj.__class__.__name__}.{name}[{i}] -> '
)
print(repr(each))
_test_attributes(each, indent_level + INDENTATION)
continue
print(f' -> {data!r}')
if is_local(data):
_test_attributes(data, indent_level + INDENTATION)
def test_attributes(obj: object) -> None:
print(f'{obj!r} -> ')
_test_attributes(obj, INDENTATION)
async def run() -> None:
async with topgg.DBLClient(os.getenv('TOPGG_TOKEN')) as tg:
bot = await tg.get_bot_info(432610292342587392)
test_attributes(bot)
await asyncio.sleep(1)
bots = await tg.get_bots(limit=250, offset=50, sort=topgg.SortBy.MONTHLY_VOTES)
for b in bots:
test_attributes(b)
await asyncio.sleep(1)
await tg.post_guild_count(topgg.StatsWrapper(2))
await asyncio.sleep(1)
posted_stats = await tg.get_guild_count()
assert posted_stats.server_count == 2
test_attributes(posted_stats)
await asyncio.sleep(1)
voters = await tg.get_bot_votes()
for voter in voters:
test_attributes(voter)
await asyncio.sleep(1)
is_weekend = await tg.get_weekend_status()
assert isinstance(is_weekend, bool)
await asyncio.sleep(1)
has_voted = await tg.get_user_vote(661200758510977084)
assert isinstance(has_voted, bool)
if __name__ == '__main__':
asyncio.run(run())