-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest_app.py
67 lines (52 loc) · 1.56 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
62
63
64
65
66
67
import uuid
from app import parse_link, Topic
from flask import url_for
def test_parse_link():
assert parse_link(u'[[Topic]]') == u'[Topic](/Topic)'
def test_topic_find(fx_session):
topic = Topic.find('test')
fx_session.add(topic)
fx_session.commit()
topic2 = Topic.find('test')
assert topic.created_at == topic2.created_at
def test_backlinks(fx_session):
foo = Topic.find('foo')
bar = Topic.find('bar')
bar.body = ''
fx_session.add(foo)
fx_session.add(bar)
fx_session.commit()
assert foo.backlinks.count() == 0
bar.body = 'test for [[foo]]'
fx_session.commit()
assert foo.backlinks.count() == 1
assert foo.backlinks[0] == bar
def test_redirect_to_readme(fx_app_client):
with fx_app_client as app:
assert app.get('/').location == url_for(
'topic',
topic=Topic.find('README')
)
def test_search(fx_app_client):
with fx_app_client as app:
assert app.get('/?topic=TEST').location == url_for(
'topic',
topic=Topic.find('TEST')
)
def test_200(fx_app_client):
urls = [
'/README',
'/README/backlinks',
'/README/edit',
'/README/keynote'
]
with fx_app_client as app:
for url in urls:
assert app.get(url).status_code == 200
def test_edit_topic(fx_app_client):
with fx_app_client as app:
test_body = str(uuid.uuid4())
rv = app.post('/README', data=dict(
body=test_body
), follow_redirects=True)
assert test_body in str(rv.data)