-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_power.py
More file actions
52 lines (40 loc) · 1.09 KB
/
test_power.py
File metadata and controls
52 lines (40 loc) · 1.09 KB
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
from app import power_of_two
def test_power_of_two():
test_cases = [
(0, 1),
(1, 2),
(2, 4),
(3, 8),
(4, 16),
(5, 32),
(6, 64),
(7, 128),
(8, 256),
(9, 512),
(10, 1024)
]
for exp, expected in test_cases:
result = power_of_two(exp)
assert result == expected
from app import app
def test_pokemon_endpoint():
client = app.test_client()
response = client.get("/pokemon/pikachu")
assert response.status_code == 200
data = response.get_json()
assert "name" in data
assert data["name"] == "pikachu"
assert "id" in data
assert "types" in data
from app import app
def test_home():
client = app.test_client()
response = client.get("/")
assert response.status_code == 200
assert response.data == b"Hello World!"
def test_echo():
client = app.test_client()
payload = {"message": "hi there"}
response = client.post("/echo", json=payload)
assert response.status_code == 200
assert response.get_json() == {"you_sent": payload}