Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dfab55

Browse files
author
Kotsias, Panagiotis-Christos
committed
Added unittests for pro module
1 parentc4b1b51 commit2dfab55

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎test/test_pro_modules.py‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
importjson
2+
fromdatetimeimportdatetime
3+
importos
4+
fromunittestimportTestCase
5+
6+
frometherscan.etherscanimportEtherscan
7+
8+
CONFIG_PATH="configs/stable.json"
9+
API_PRO_KEY=os.environ["API_PRO_KEY"]# Encrypted env var by Travis
10+
11+
12+
defload(fname):
13+
withopen(fname,"r")asf:
14+
returnjson.load(f)
15+
16+
17+
defdump(data,fname):
18+
withopen(fname,"w")asf:
19+
json.dump(data,f,indent=2)
20+
21+
22+
classCase(TestCase):
23+
_MODULE=""
24+
25+
deftest_methods(self):
26+
print(f"\nMODULE:{self._MODULE}")
27+
config=load(CONFIG_PATH)
28+
etherscan=Etherscan.from_config(CONFIG_PATH,API_PRO_KEY)
29+
forfun,vinconfig.items():
30+
ifnotfun.startswith("_"):# disabled if _
31+
ifv["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+
classTestProModules(Case):
47+
_MODULE="pro"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp