From 50a4d22c2149cf7c18d3d9c961d8ba4ed0a74368 Mon Sep 17 00:00:00 2001 From: devyad24 Date: Tue, 26 Mar 2024 20:18:34 +0530 Subject: [PATCH] Add tests for blog GET and POST routes --- ...dd_url_field_in_posts_model.cpython-36.pyc | Bin 838 -> 838 bytes ...590e2e6e_create_posts_table.cpython-36.pyc | Bin 1103 -> 1103 bytes lib/__pycache__/util_datetime.cpython-36.pyc | Bin 1205 -> 1205 bytes .../util_sqlalchemy.cpython-36.pyc | Bin 4237 -> 4237 bytes requirements.txt | 2 ++ test_blog.py | 22 ++++++++++++++++++ 6 files changed, 24 insertions(+) create mode 100644 test_blog.py diff --git a/blogexample/migrations/versions/__pycache__/29d9055c6a28_create_add_url_field_in_posts_model.cpython-36.pyc b/blogexample/migrations/versions/__pycache__/29d9055c6a28_create_add_url_field_in_posts_model.cpython-36.pyc index 4fecab943c3b6d40a984e32f85d17c3d69f68ed1..5681a57c533ada9460cb00e6ca100b9a20464473 100644 GIT binary patch delta 18 ZcmX@cc8rbFn3tF9?_Q>~IU6}`nE^Lx1+f4C delta 18 ZcmX@cc8rbFn3tD}{drGf#YRqBW&kq>1x5e> diff --git a/blogexample/migrations/versions/__pycache__/5deb590e2e6e_create_posts_table.cpython-36.pyc b/blogexample/migrations/versions/__pycache__/5deb590e2e6e_create_posts_table.cpython-36.pyc index 46ad92907d20e59e771cd66cac6644b54c4f849c..1ebda1c8ed69380ff0e9314aeb1c21bd72d38e52 100644 GIT binary patch delta 19 acmX@lah`+An3tF9?_Q=fIo6F_t}FmL@C8`_ delta 19 acmX@lah`+An3tD}{drH~Czg#|t}FmM?gixl diff --git a/lib/__pycache__/util_datetime.cpython-36.pyc b/lib/__pycache__/util_datetime.cpython-36.pyc index a0f68043ce1aa63b5cbf03393dcb80c2622b6876..573ed2455540c59acffcb6fbc2ee6a15964bd9f2 100644 GIT binary patch delta 18 acmdnWxs{XCn3tF9?_Q>~9~(K>umAu!G6rD) delta 18 ZcmdnWxs{XCn3tD}{drH~sg0a#SO7Dg1?&I- diff --git a/lib/__pycache__/util_sqlalchemy.cpython-36.pyc b/lib/__pycache__/util_sqlalchemy.cpython-36.pyc index f9874a68d257af7fc47e8259375f455b97bcdadf..4b3bd3dd8c9db020d18945f462cc8755dd037e43 100644 GIT binary patch delta 19 acmeBG>{aA4=H=!3yO$}=jDI6nvj6}#L{aA4=H=yLf8LY0iEkrUvj6}!G6kmq diff --git a/requirements.txt b/requirements.txt index d5f92bc..f6c63d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,3 +20,5 @@ WTForms-Alchemy==0.16.9 flask_ckeditor pytz +pytest +requests diff --git a/test_blog.py b/test_blog.py new file mode 100644 index 0000000..037231b --- /dev/null +++ b/test_blog.py @@ -0,0 +1,22 @@ +import requests + +ENDPOINT = 'http://localhost:8000/' + +def test_can_call_endpoint(): + response = requests.get(ENDPOINT) + assert response.status_code == 200 + +def test_can_create_post(): + payload = { + "title": "Post 3", + "body": "Body 3", + "taglist":"", + "visible": "y" + } + response = requests.post(ENDPOINT + "/add", json=payload) + assert response.status_code == 200 + + +# def test_can_delete_post(): + + \ No newline at end of file