-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_app.py
59 lines (48 loc) · 1.73 KB
/
test_app.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
from app import app
from gcp import access_secret_version
from config import FB_CHALLENGE
import json
data_file = "skills.json"
def test_webhook_challenge_rejected():
token = "incorrect token bla-bla"
response = app.test_client().get(
"/webhook?hub.verify_token="
+ token
+ "&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"
)
assert response.status_code == 403
def test_webhook_challenge_accepted():
token = FB_CHALLENGE
response = app.test_client().get(
"/webhook?hub.verify_token="
+ token
+ "&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"
)
assert response.status_code == 200
assert response.data == b"CHALLENGE_ACCEPTED"
def test_check_data_file():
with open(data_file) as json_file:
skills = json.load(json_file)["skills"]
assert len(skills) > 0
for skill in skills:
assert skill.get("name")
assert skill.get("image_url")
assert skill.get("assignments")
has_advanced_level = False
for assignment in skill.get("assignments"):
assert assignment.get("type")
assert assignment.get("name")
assert assignment.get("author")
assert assignment.get("release_date")
assert assignment.get("level") >= 0
assert assignment.get("rating")
assert assignment.get("url")
assert assignment.get("time_hours")
if assignment.get("level") == 2:
has_advanced_level = True
print(skill.get("name"))
assert has_advanced_level == True
# def inc(x):
# return x + 1
# def test_answer():
# assert inc(3) == 5