examples/blog/tests/test_blog.py
raw| 1 | from blog import app |
| 2 | |
| 3 | |
| 4 | async def test_create_post(): |
| 5 | test_client = app.test_client() |
| 6 | response = await test_client.post( |
| 7 | "/create/", form={"title": "Post", "text": "Text"} |
| 8 | ) |
| 9 | assert response.status_code == 302 |
| 10 | response = await test_client.get("/") |
| 11 | text = await response.get_data() |
| 12 | assert b"<h2>Post</h2>" in text |
| 13 | assert b"<p>Text</p>" in text |