-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_app.py
61 lines (47 loc) · 1.5 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
60
61
from app import get_location, get_address
import pytest
from app import app
def test_get_location():
address = get_location("15.5622056666667", "32.5655843333333")
assert address.raw["address"]["city"] == "الخرطوم"
assert address.raw["address"]["neighbourhood"] == "الطائف"
def test_get_address():
address = get_address("15.5622056666667", "32.5655843333333")
assert address == "الطائف, الخرطوم, ولاية الخرطوم, 11114, السودان \u200eal-Sūdān"
@pytest.fixture
def client():
with app.test_client() as client:
with app.app_context():
pass
yield client
def test_send_req_400(client):
res = client.post("/", json={"lat": 20})
assert res.status_code == 400
def test_send_req_200(client):
res = client.post(
"/",
json={
"lat": 20,
"long": 32,
"long_describtion": "my long",
"short_describtion": "short",
},
)
assert res.status_code == 200
assert res.mimetype == "application/json"
def test_send_req_type(client):
res = client.post(
"/",
json={
"lat": 20,
"long": 32,
"long_describtion": "my long",
"short_describtion": "short",
},
)
assert res.mimetype == "application/json"
def test_get_without_query(client):
res = client.get("/get")
assert res.status_code == 200
assert res.mimetype == "application/json"
assert len(res.json()) > 1