-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_app.py
55 lines (43 loc) · 1.36 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
import os
import pytest
import tempfile
from kanban import app, db
@pytest.fixture
def client():
db_fd, url = tempfile.mkstemp()
url = 'sqlite://' + url
app.config['DATABASE'] = url
app.config['TESTING'] = True
client = app.test_client()
yield client
os.close(db_fd)
os.unlink(app.config['DATABASE'])
def test_empty_db(client):
"""Start with a blank database."""
rv = client.get('/')
assert b'Oops, you have no active tasks. Add tasks now!' in rv.data
def add(client,newtask_name,newtask_desc,newtask_status):
return client.post('/add/',data=dict(
newtask_name=newtask_name,
newtask_desc=newtask_desc,
newtask_status=newtask_status
), follow_redirects=True)
def test_add(client):
rv = add(client,"task","task-desc","todo")
assert b'Get started!' in rv.data
def update(client):
return client.post('/update/1/', follow_redirects=True)
def test_update_todoing(client):
rv = add(client,"task","task-desc","todo")
rv = update(client)
assert b'Done!' in rv.data
def test_update_todone(client):
rv = add(client,"task","task-desc","doing")
rv = update(client)
assert b'Clear' in rv.data
def test_update_clear(client):
rv = add(client,"task","task-desc","done")
rv = update(client)
assert b'task-desc' not in rv.data
if __name__ == '__main__':
unittest.main()