forked from StepicOrg/Stepik-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_examples.py
More file actions
20 lines (18 loc) · 753 Bytes
/
test_examples.py
File metadata and controls
20 lines (18 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def test_oauth_auth_example():
import ast
import _ast
import codegen
client_id = "n4mnzQGfDEfOhFixwBvLV2mZJJLvf86pzfMMiPF5"
client_secret = "40ON9IPJRDAngUkVbGBTEjCBAwc2wB7lV8e71jJUPKabdKq6KBTUBKb1xGkh82KtAI1AqISrL3Zi4sTfhCBVh27YvlV6Y5klpXXV5loUWvuhMSRiN3HRZzVDO0fLBibv"
with open("examples/oauth_auth_example.py", "r") as f:
data = f.read()
p = ast.parse(data)
for node in p.body:
if type(node) == _ast.Assign:
if node.targets[0].id == 'client_id':
node.value.s = client_id
if node.targets[0].id == 'client_secret':
node.value.s = client_secret
ls = {}
exec(codegen.to_source(p), ls)
assert ls['course']['courses'][0]['id'] == 67