forked from ton-society/the-open-league
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_runner.py
62 lines (58 loc) · 2.6 KB
/
test_runner.py
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
"""
Test runner for github tests
"""
import os
import sys
import psycopg2
from loguru import logger
from backends.contracts_executor import ContractsExecutor
from backends.defillama.tvl import DefillamaDeFiTVLBackend
from backends.defillama.volume import DefillamaDeFiVolumeBackend
from backends.sbt_enrollment import SBTEnrollmentSync
from backends.redoubt.apps import RedoubtAppBackend
from backends.redoubt.apps_v2 import RedoubtAppBackendV2
from backends.toncenter_cpp.apps_v2_users import ToncenterCppAppBackendV2Users
from backends.toncenter_cpp.nfts import ToncenterCppNFTsBackend
from backends.redoubt.tokens import RedoubtTokensBackend
from backends.tonapi import TonapiAdapter
from backends.toncenter_cpp.apps_v2_projects import ToncenterCppAppsScores2Projects
from models.render_method import JsonRenderMethod, HTMLRenderMethod
from models.season_config import SeasonConfig
from seasons.s6 import S6_apps, S6_nfts, S6_defi_tvl, S6_defi_volume
if __name__ == "__main__":
with psycopg2.connect() as conn:
if sys.argv[1] == 'apps_v2':
backend = ToncenterCppAppBackendV2Users(conn, produce_output=True)
season = S6_apps
backend.calculate(season, dry_run=len(sys.argv) > 2 and sys.argv[2] == '--dryrun')
elif sys.argv[1] == 'apps_v2_projects':
backend = ToncenterCppAppsScores2Projects(conn)
season = S6_apps
backend.calculate(season, dry_run=len(sys.argv) > 2 and sys.argv[2] == '--dryrun')
elif sys.argv[1] == 'nfts':
backend = ToncenterCppNFTsBackend(conn)
season = S6_nfts
elif sys.argv[1] == 'defi_tvl':
backend = DefillamaDeFiTVLBackend(
tonapi=TonapiAdapter(),
executor=ContractsExecutor(os.getenv('CONTRACTS_EXECUTOR_URL'))
)
season = S6_defi_tvl
elif sys.argv[1] == 'defi_volume':
backend = DefillamaDeFiVolumeBackend()
season = S6_defi_volume
elif sys.argv[1] == 'sbt':
backend = SBTEnrollmentSync(conn,
tonapi=TonapiAdapter(),
executor=ContractsExecutor(os.getenv('CONTRACTS_EXECUTOR_URL')))
season = S6_apps
backend.sync(season)
sys.exit(0)
else:
raise Exception(f"leaderboard not supported: {sys.argv[1]}")
res = backend.calculate(season, dry_run=len(sys.argv) > 2 and sys.argv[2] == '--dryrun')
logger.info(res)
render = JsonRenderMethod("output.json")
render.render(res, season)
render = HTMLRenderMethod("output.html")
render.render(res, season)