-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_hostname.py
52 lines (34 loc) · 1.14 KB
/
test_hostname.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
import json
import platform
import pytest
from main import create_app
@pytest.fixture(scope="module")
def test_client():
app = create_app()
app.config["TESTING"] = True
app.config["BCRYPT_LOG_ROUNDS"] = 4
app.config["WTF_CSRF_ENABLED"] = False
testing_client = app.test_client()
context = app.app_context()
context.push()
yield testing_client
context.pop()
@pytest.mark.unit
def test_hostname(test_client):
response = test_client.get("/v1/host")
actual_hostname = platform.node()
assert response.status_code == 200
response_json = json.loads(response.data)
assert response_json["backend_host"] == actual_hostname
@pytest.mark.unit
def test_root_url_redirects(test_client):
response = test_client.get("/")
actual_hostname = platform.node()
assert response.status_code == 302
@pytest.mark.unit
def test_root_url_returns_host(test_client):
response = test_client.get("/", follow_redirects=True)
actual_hostname = platform.node()
assert response.status_code == 200
response_json = json.loads(response.data)
assert response_json["backend_host"] == actual_hostname