-
Notifications
You must be signed in to change notification settings - Fork 1
Modularize app structure #2
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
Changes from all commits
159d610
9a7c90f
d5a287c
769d378
ac8269f
6e7f474
b64bd48
e584c11
54bf43a
b55ad4a
16b3c91
b531ed8
543c28b
e46aba2
3d26b71
00c711f
f46c5dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ Collection of helper fucntions """ | ||
| """ Collection of helper functions """ | ||
|
|
||
| from urllib.parse import urljoin | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| """Entry point for running the Flask application. | ||
|
|
||
| This script imports the Flask application factory from the app package, | ||
| creates an instance of the application, and runs it in debug mode. | ||
| """ | ||
| from app import create_app | ||
|
|
||
| app = create_app() |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,18 +1,17 @@ | ||||||||||
| # pylint: disable=missing-docstring | ||||||||||
|
|
||||||||||
| # Filepath is this: /Users/Shanti.Rai@methods.co.uk/Documents/S_BookAPIV.2/tests/test_app.py | ||||||||||
|
|
||||||||||
| from unittest.mock import patch | ||||||||||
| from pymongo.errors import ServerSelectionTimeoutError | ||||||||||
| import pytest | ||||||||||
| from app.datastore.mongo_db import get_book_collection | ||||||||||
| from app import app | ||||||||||
| from app import create_app | ||||||||||
|
|
||||||||||
|
|
||||||||||
| # Option 1: Rename the fixture to something unique (which I've used) | ||||||||||
| # Option 2: Use a linter plugin that understands pytest | ||||||||||
| @pytest.fixture(name="client") | ||||||||||
| def client_fixture(): | ||||||||||
| app = create_app() | ||||||||||
| app.config['TESTING'] = True | ||||||||||
| return app.test_client() | ||||||||||
|
|
||||||||||
|
|
@@ -561,6 +560,7 @@ def test_get_book_collection_handles_connection_failure(): | |||||||||
| # Set the side effect to raise a ServerSelectionTimeoutError | ||||||||||
| mock_client.side_effect = ServerSelectionTimeoutError("Mock Connection Timeout") | ||||||||||
|
|
||||||||||
| app = create_app() | ||||||||||
|
||||||||||
| app = create_app() | |
| app = create_app() | |
| app.config['MONGO_URI'] = "mongodb://localhost:27017/test_db" | |
| app.config['DB_NAME'] = "test_db" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| # pylint: disable=missing-docstring | ||
| import pytest | ||
| from pymongo import MongoClient | ||
| from app import app | ||
| from app import create_app | ||
|
|
||
|
|
||
| @pytest.fixture(name="client") | ||
| def client_fixture(): | ||
| """Provides a test client for making requests to our Flask app.""" | ||
| app = create_app() | ||
| app.config['TESTING'] = True | ||
| app.config['MONGO_URI'] = 'mongodb://localhost:27017/' | ||
| app.config['DB_NAME'] = 'test_database' | ||
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This looks like a debug print and may clutter production logs. Consider removing or replacing with a proper logger call.