-
Notifications
You must be signed in to change notification settings - Fork 6
fix: 2 corrections on gbfs populate #1265
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
692c26d
Deprecated feeds removed form systems.csv and stopped processing feed…
jcpitre e73a744
Removed an unused line
jcpitre 82badd6
Merge branch 'main' into 1242-gbfs-feeds-are-not-being-removed-from-api
jcpitre 40ad4e6
Added tests
jcpitre 4e86941
Added cascade delete for DB entities where required.
jcpitre 4d7be0c
Merge branch 'main' into 1242-gbfs-feeds-are-not-being-removed-from-api
jcpitre b68bfbb
Corrected a problem cascade deletes during operations_api tests
jcpitre 62eddbf
Corrected typos and useless comments.
jcpitre 56e77fb
Removed useless comments.
jcpitre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import os | ||
|
|
||
| import pytest | ||
| from fastapi import FastAPI | ||
| from fastapi.testclient import TestClient | ||
| from sqlalchemy import text | ||
|
|
||
| from shared.database.database import Database | ||
| from main import app as application | ||
| from tests.test_utils.database import populate_database | ||
|
|
||
|
|
||
| @pytest.fixture(scope="package") | ||
| def app() -> FastAPI: | ||
| application.dependency_overrides = {} | ||
| return application | ||
|
|
||
|
|
||
| @pytest.fixture(scope="package") | ||
| def test_database(): | ||
| # Restrict the tests to the test database | ||
| os.environ["FEEDS_DATABASE_URL"] = "postgresql://postgres:postgres@localhost:54320/MobilityDatabaseTest" | ||
|
|
||
| data_dirs = [] | ||
| second_phase_data_dirs = [] | ||
| with populate_database(Database(), data_dirs, second_phase_data_dirs) as db: | ||
| yield db | ||
|
|
||
|
|
||
| @pytest.fixture(scope="package") | ||
| def client(app, test_database) -> TestClient: | ||
| return TestClient(app) | ||
|
|
||
|
|
||
| # We want to delete all data from the database after each test so we don't have to coordinate the DB ids between tests. | ||
| @pytest.fixture(autouse=True) | ||
| def clean_database(test_database, request): | ||
| yield | ||
| # Check if the test passed | ||
| if request.node.rep_call.outcome == "passed": | ||
| with test_database.start_db_session() as session: | ||
| for table in session.execute(text("SELECT tablename FROM pg_tables WHERE schemaname = 'public'")): | ||
| session.execute(text(f"TRUNCATE {table[0]} CASCADE")) | ||
| session.commit() | ||
|
|
||
|
|
||
| @pytest.hookimpl(tryfirst=True, hookwrapper=True) | ||
| def pytest_runtest_makereport(item, call): | ||
| # Attach test result to the request object | ||
| outcome = yield | ||
| report = outcome.get_result() | ||
| setattr(item, f"rep_{call.when}", report) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍