-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_flask.py
67 lines (56 loc) · 2.24 KB
/
test_flask.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
62
63
64
65
66
67
import pytest
import app
@pytest.fixture
def apptest():
apptest = app.create_app()
apptest.debug = True
return apptest.test_client()
def test_hello_world(apptest):
res = apptest.get("/")
# print(dir(res), res.status_code)
assert res.status_code == 200
assert b"Hello, World!" in res.data
def login(client, username, password):
return client.post('/login', data=dict(
username=username,
password=password
), follow_redirects=True)
def test_registration(apptest):
res = apptest.get("/register")
# print(dir(res), res.status_code)
assert res.status_code == 200
assert b"Registration" in res.data
def test_registration_no2fa(apptest):
response = apptest.post('/register',
data=dict(uname='user1', pword='FlaskIsAwesome'),
follow_redirects=True)
assert response.status_code == 200
assert b"Success. Your username is user1" in response.data
def test_registration_2fa(apptest):
response = apptest.post('/register',
data=dict(uname='user2', pword='FlaskIsAwesome2', twofa='1234567890'),
follow_redirects=True)
assert response.status_code == 200
assert b"Success. Your username is user2" in response.data
def test_login(apptest):
res = apptest.get("/login")
# print(dir(res), res.status_code)
assert res.status_code == 200
assert b"Login" in res.data
def test_login_user(apptest):
response = apptest.post('/register',
data=dict(uname='user1', pword='FlaskIsAwesome'),
follow_redirects=True)
assert response.status_code == 200
assert b"Success" in response.data
def test_login_user2fa(apptest):
response = apptest.post('/register',
data=dict(uname='user2', pword='FlaskIsAwesome2', twofa='1234567890'),
follow_redirects=True)
assert response.status_code == 200
assert b"Success" in response.data
def test_spellcheck(apptest):
res = apptest.get("/spell_check")
# print(dir(res), res.status_code)
assert res.status_code == 200
assert b"Spell Check Tool" in res.data