Skip to content

Added Result for pytest #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ services:
- '8000:8000'

volumes:
postgres:

postgres:
Binary file modified lib/__pycache__/util_datetime.cpython-36.pyc
Binary file not shown.
Binary file modified lib/__pycache__/util_sqlalchemy.cpython-36.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = tests
Binary file modified requirements.txt
Binary file not shown.
Binary file added results/terminal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -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