-
Notifications
You must be signed in to change notification settings - Fork 0
Initialize modules, enhance API, and add CI for testing #3
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
5 commits
Select commit
Hold shift + click to select a range
23a4559
feat: Initialize modules and add __init__.py files for core, exceptio…
WillianSilva51 72ab26b
feat: Update API key placeholder in .env-example and enhance RedisCac…
WillianSilva51 73e608e
feat: Enhance pagination parameters for get_all_quotes and get_random…
WillianSilva51 9888277
feat: Refactor Create Quote API and enhance test structure with valid…
WillianSilva51 552bd37
feat: Add GitHub Actions workflow for Python tests and linting, and u…
WillianSilva51 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Python Application Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test-lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Install the latest version of uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --frozen | ||
|
|
||
| - name: Lint | ||
| run: uv run ruff check . --output-format=github | ||
|
|
||
| - name: Test with pytest | ||
| run: uv run pytest |
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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| MONGO_URI=mongodb://user:password123@localhost:27017/finfrases?authSource=admin | ||
|
|
||
| API_KEY=ampyLVT7rSby5SZtFUK7RLiwlsUt5igG3tB0cWhcIB8 | ||
| API_KEY=CHANGE_ME |
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 |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ variables: | |
| value: v1 | ||
| - name: baseUrl | ||
| value: http://localhost:8000/api | ||
| - secret: true | ||
| name: API_KEY | ||
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,3 @@ | ||
| from . import cache, quote_service, quote_repository, security | ||
|
|
||
| __all__ = ["cache", "quote_service", "quote_repository", "security"] | ||
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
Empty file.
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,3 @@ | ||
| from . import enums, quote | ||
|
|
||
| __all__ = ["enums", "quote"] |
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,3 @@ | ||
| from . import quote_repository | ||
|
|
||
| __all__ = ["quote_repository"] |
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,3 @@ | ||
| from . import quotes | ||
|
|
||
| __all__ = ["quotes"] |
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,3 @@ | ||
| from . import pagination, quote_schema | ||
|
|
||
| __all__ = ["pagination", "quote_schema"] |
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,3 @@ | ||
| from . import quote_service | ||
|
|
||
| __all__ = ["quote_service"] |
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,3 @@ | ||
| from . import test_quote_service | ||
|
|
||
| __all__ = ["test_quote_service"] |
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,53 @@ | ||
| from unittest.mock import AsyncMock | ||
|
|
||
| import pytest | ||
| from models.enums import CategoryQuote | ||
| from models.quote import Quote | ||
| from repositories.quote_repository import QuoteRepository | ||
| from schemas.quote_schema import CreateQuoteRequest | ||
| from services.quote_service import QuoteService | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def service(): | ||
| return QuoteService() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_repo(): | ||
| return AsyncMock(spec=QuoteRepository) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def valid_request_data(): | ||
| return CreateQuoteRequest( | ||
| content="Investir é sobre ter paciência.", | ||
| author="Warren Buffett", | ||
| tags=[CategoryQuote.INVESTIMENTOS, CategoryQuote.EDUCACAO], | ||
| source="Book of Finances", | ||
| verified=True, | ||
| ) | ||
|
|
||
|
|
||
| class TestCreateQuote: | ||
| @pytest.mark.asyncio | ||
| async def test_create_quote_sucess(self, service, mock_repo, valid_request_data): | ||
WillianSilva51 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| quote = Quote.model_construct( | ||
| content=valid_request_data.content, | ||
| author=valid_request_data.author, | ||
| tags=valid_request_data.tags, | ||
| source=valid_request_data.source, | ||
| verified=valid_request_data.verified, | ||
| ) | ||
|
|
||
| mock_repo.create.return_value = quote | ||
|
|
||
| result = await service.create_quote(quote=valid_request_data, repo=mock_repo) | ||
|
|
||
| assert result.content == valid_request_data.content | ||
| assert result.author == valid_request_data.author | ||
| assert result.tags == valid_request_data.tags | ||
| assert result.source == valid_request_data.source | ||
| assert result.verified == valid_request_data.verified | ||
|
|
||
| mock_repo.create.assert_called_once_with(valid_request_data) | ||
WillianSilva51 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,3 @@ | ||
| from . import utils | ||
|
|
||
| __all__ = ["utils"] |
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,83 @@ | ||
| altair==6.0.0 | ||
| annotated-doc==0.0.4 | ||
| annotated-types==0.7.0 | ||
| anyio==4.13.0 | ||
| attrs==26.1.0 | ||
| beanie==2.0.1 | ||
| blinker==1.9.0 | ||
| cachetools==7.0.5 | ||
| certifi==2026.2.25 | ||
| charset-normalizer==3.4.6 | ||
| click==8.3.1 | ||
| dnspython==2.8.0 | ||
| email-validator==2.3.0 | ||
| fastapi==0.135.2 | ||
| fastapi-cli==0.0.24 | ||
| fastapi-cloud-cli==0.15.0 | ||
| fastar==0.9.0 | ||
| gitdb==4.0.12 | ||
| gitpython==3.1.46 | ||
| h11==0.16.0 | ||
| hiredis==3.3.1 | ||
| httpcore==1.0.9 | ||
| httptools==0.7.1 | ||
| httpx==0.28.1 | ||
| idna==3.11 | ||
| iniconfig==2.3.0 | ||
| jinja2==3.1.6 | ||
| jsonschema==4.26.0 | ||
| jsonschema-specifications==2025.9.1 | ||
| lazy-model==0.4.0 | ||
| loguru==0.7.3 | ||
| markdown-it-py==4.0.0 | ||
| markupsafe==3.0.3 | ||
| mdurl==0.1.2 | ||
| narwhals==2.18.1 | ||
| numpy==2.4.3 | ||
| packaging==26.0 | ||
| pandas==2.3.3 | ||
| pillow==12.1.1 | ||
| pluggy==1.6.0 | ||
| protobuf==6.33.6 | ||
| pyarrow==23.0.1 | ||
| pydantic==2.12.5 | ||
| pydantic-core==2.41.5 | ||
| pydantic-extra-types==2.11.1 | ||
| pydantic-settings==2.13.1 | ||
| pydeck==0.9.1 | ||
| pygments==2.19.2 | ||
| pymongo==4.16.0 | ||
| pytest==9.0.2 | ||
| pytest-asyncio==1.3.0 | ||
| python-dateutil==2.9.0.post0 | ||
| python-dotenv==1.2.2 | ||
| python-multipart==0.0.22 | ||
| pytz==2026.1.post1 | ||
| pyyaml==6.0.3 | ||
| redis==7.4.0 | ||
| referencing==0.37.0 | ||
| requests==2.33.0 | ||
| rich==14.3.3 | ||
| rich-toolkit==0.19.7 | ||
| rignore==0.7.6 | ||
| rpds-py==0.30.0 | ||
| ruff==0.15.8 | ||
| sentry-sdk==2.56.0 | ||
| shellingham==1.5.4 | ||
| six==1.17.0 | ||
| smmap==5.0.3 | ||
| starlette==1.0.0 | ||
| streamlit==1.55.0 | ||
| tenacity==9.1.4 | ||
| toml==0.10.2 | ||
| tornado==6.5.5 | ||
| typer==0.24.1 | ||
| typing-extensions==4.15.0 | ||
| typing-inspection==0.4.2 | ||
| tzdata==2025.3 | ||
| urllib3==2.6.3 | ||
| uvicorn==0.42.0 | ||
| uvloop==0.22.1 | ||
| watchdog==6.0.0 | ||
| watchfiles==1.1.1 | ||
| websockets==16.0 |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.