generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 create filing period get route (#41)
Closes #40 - Added /periods route to filing.py, along with the supporting get_session function for db connections - Added get_filing_periods function to submission_repo to return all FilingPeriod objects in the db - Added pytests for the route and the new submission_repo function
- Loading branch information
Showing
7 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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,30 @@ | ||
import pytest | ||
|
||
from datetime import datetime | ||
from fastapi import FastAPI | ||
from pytest_mock import MockerFixture | ||
from unittest.mock import Mock | ||
|
||
from entities.models import FilingPeriodDAO, FilingType | ||
|
||
|
||
@pytest.fixture | ||
def app_fixture(mocker: MockerFixture) -> FastAPI: | ||
from main import app | ||
|
||
return app | ||
|
||
|
||
@pytest.fixture | ||
def get_filing_period_mock(mocker: MockerFixture) -> Mock: | ||
mock = mocker.patch("entities.repos.submission_repo.get_filing_periods") | ||
mock.return_value = [ | ||
FilingPeriodDAO( | ||
name="FilingPeriod2024", | ||
start_period=datetime.now(), | ||
end_period=datetime.now(), | ||
due=datetime.now(), | ||
filing_type=FilingType.MANUAL, | ||
) | ||
] | ||
return mock |
This file contains 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,14 @@ | ||
from unittest.mock import Mock | ||
|
||
from fastapi import FastAPI | ||
from fastapi.testclient import TestClient | ||
from pytest_mock import MockerFixture | ||
|
||
|
||
class TestFilingApi: | ||
def test_get_periods(self, mocker: MockerFixture, app_fixture: FastAPI, get_filing_period_mock: Mock): | ||
client = TestClient(app_fixture) | ||
res = client.get("/v1/filing/periods") | ||
assert res.status_code == 200 | ||
assert len(res.json()) == 1 | ||
assert res.json()[0]["name"] == "FilingPeriod2024" |
This file contains 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