Refactor test system to be more extendable, add comment test
This commit is contained in:
parent
23a8fb9663
commit
e257db1542
8 changed files with 147 additions and 59 deletions
54
files/tests/test_basic.py
Normal file
54
files/tests/test_basic.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
from . import fixture_accounts
|
||||
from . import util
|
||||
|
||||
def test_rules(accounts):
|
||||
response = accounts.logged_off().get("/rules")
|
||||
assert response.status_code == 200
|
||||
assert response.text.startswith("<!DOCTYPE html>")
|
||||
|
||||
|
||||
def test_post_and_comment(accounts):
|
||||
client = accounts.client_for_account()
|
||||
|
||||
# get our formkey
|
||||
submit_get_response = client.get("/submit")
|
||||
assert submit_get_response.status_code == 200
|
||||
|
||||
# make the post
|
||||
post_title = util.generate_text()
|
||||
post_body = util.generate_text()
|
||||
submit_post_response = client.post("/submit", data={
|
||||
"title": post_title,
|
||||
"body": post_body,
|
||||
"formkey": util.formkey_from(submit_get_response.text),
|
||||
})
|
||||
|
||||
assert submit_post_response.status_code == 200
|
||||
assert post_title in submit_post_response.text
|
||||
assert post_body in submit_post_response.text
|
||||
|
||||
# verify it actually got posted
|
||||
root_response = client.get("/")
|
||||
assert root_response.status_code == 200
|
||||
assert post_title in root_response.text
|
||||
assert post_body in root_response.text
|
||||
|
||||
# yank the ID out
|
||||
post = util.ItemData.from_html(submit_post_response.text)
|
||||
|
||||
# post a comment child
|
||||
comment_body = util.generate_text()
|
||||
submit_comment_response = client.post("/comment", data={
|
||||
"parent_fullname": post.id_full,
|
||||
"parent_level": 1,
|
||||
"submission": post.id,
|
||||
"body": comment_body,
|
||||
"formkey": util.formkey_from(submit_post_response.text),
|
||||
})
|
||||
assert submit_comment_response.status_code == 200
|
||||
|
||||
# verify it actually got posted
|
||||
post_response = client.get(post.url)
|
||||
assert post_response.status_code == 200
|
||||
assert comment_body in post_response.text
|
Loading…
Add table
Add a link
Reference in a new issue