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 4fecab9..d73a22c 100644 Binary files a/blogexample/migrations/versions/__pycache__/29d9055c6a28_create_add_url_field_in_posts_model.cpython-36.pyc and b/blogexample/migrations/versions/__pycache__/29d9055c6a28_create_add_url_field_in_posts_model.cpython-36.pyc differ 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 46ad929..f60655e 100644 Binary files a/blogexample/migrations/versions/__pycache__/5deb590e2e6e_create_posts_table.cpython-36.pyc and b/blogexample/migrations/versions/__pycache__/5deb590e2e6e_create_posts_table.cpython-36.pyc differ diff --git a/docker-compose.yml b/docker-compose.yml index 352ac34..8ba3053 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,5 +26,4 @@ services: - '8000:8000' volumes: - postgres: - + postgres: \ No newline at end of file diff --git a/lib/__pycache__/util_datetime.cpython-36.pyc b/lib/__pycache__/util_datetime.cpython-36.pyc index a0f6804..eab6d33 100644 Binary files a/lib/__pycache__/util_datetime.cpython-36.pyc and b/lib/__pycache__/util_datetime.cpython-36.pyc differ diff --git a/lib/__pycache__/util_sqlalchemy.cpython-36.pyc b/lib/__pycache__/util_sqlalchemy.cpython-36.pyc index f9874a6..25b848f 100644 Binary files a/lib/__pycache__/util_sqlalchemy.cpython-36.pyc and b/lib/__pycache__/util_sqlalchemy.cpython-36.pyc differ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..de19c9f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = tests \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d5f92bc..ca753d9 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/results/terminal.jpg b/results/terminal.jpg new file mode 100644 index 0000000..252f39c Binary files /dev/null and b/results/terminal.jpg differ diff --git a/tests/test_views.py b/tests/test_views.py new file mode 100644 index 0000000..af19474 --- /dev/null +++ b/tests/test_views.py @@ -0,0 +1,54 @@ +import pytest +import sys +import os +from flask import url_for + +# Add the Flask app directory to sys.path + +sys.path.append(os.getcwd()) +# sys.path.append("C://Users//shiva//OneDrive//Desktop//khat//blog-blueprint-flask-sqlalchemy//") + + + +# Import create_app function from app module +from blogexample.app import create_app +from blogexample.blueprints.blog.models import Post, Tag + +@pytest.fixture(scope='module') +def app(): + app = create_app() + app.config['TESTING'] = True + return app + +@pytest.fixture(scope='module') +def client(app): + return app.test_client() + +@pytest.fixture(autouse=True) +def setup_teardown(): + with create_app().app_context(): + yield + # Teardown if needed + +def test_index(client): + response = client.get(url_for('blog.index')) + assert response.status_code == 200 + +# def test_view_post(client): +# # Create a test post +# test_post = Post(title="Test Post", body="This is a test post body") +# test_post.save() + +# # Get the post by its ID +# response = client.get(url_for('blog.view_post', post_id=test_post.id)) + +# # Check if the response is successful +# assert response.status_code == 200 + +# # Check if the post title and body are in the response data +# assert b"Test Post" in response.data +# assert b"This is a test post body" in response.data + + + +# if you give me some time i can build test for all routes