File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ import json
2+ from datetime import datetime
3+ import os
4+ from unittest import TestCase
5+
6+ from etherscan .etherscan import Etherscan
7+
8+ CONFIG_PATH = "configs/stable.json"
9+ API_PRO_KEY = os .environ ["API_PRO_KEY" ] # Encrypted env var by Travis
10+
11+
12+ def load (fname ):
13+ with open (fname , "r" ) as f :
14+ return json .load (f )
15+
16+
17+ def dump (data , fname ):
18+ with open (fname , "w" ) as f :
19+ json .dump (data , f , indent = 2 )
20+
21+
22+ class Case (TestCase ):
23+ _MODULE = ""
24+
25+ def test_methods (self ):
26+ print (f"\n MODULE: { self ._MODULE } " )
27+ config = load (CONFIG_PATH )
28+ etherscan = Etherscan .from_config (CONFIG_PATH , API_PRO_KEY )
29+ for fun , v in config .items ():
30+ if not fun .startswith ("_" ): # disabled if _
31+ if v ["module" ] == self ._MODULE :
32+ res = getattr (etherscan , fun )(** v ["kwargs" ])
33+ print (f"METHOD: { fun } , RTYPE: { type (res )} " )
34+ # Create log files (will update existing ones)
35+ fname = f"logs/{ fun } .json"
36+ log = {
37+ "method" : fun ,
38+ "module" : v ["module" ],
39+ "kwargs" : v ["kwargs" ],
40+ "log_timestamp" : datetime .now ().strftime ("%Y-%m-%d-%H:%M:%S" ),
41+ "res" : res ,
42+ }
43+ dump (log , fname )
44+
45+
46+ class TestProModules (Case ):
47+ _MODULE = "pro"
You can’t perform that action at this time.
0 commit comments