-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
70 additions
and
76 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
from falcon import Request, Response | ||
from ebl.errors import NotFoundError | ||
|
||
from ebl.dossiers.application.dossier_repository import DossierRepository | ||
from ebl.dossiers.infrastructure.mongo_dossier_repository import ( | ||
from ebl.dossiers.application.dossiers_repository import DossiersRepository | ||
from ebl.dossiers.infrastructure.mongo_dossiers_repository import ( | ||
DossierRecordSchema, | ||
) | ||
|
||
|
||
class DossierResource: | ||
def __init__(self, _dossierRepository: DossierRepository): | ||
self._dossierRepository = _dossierRepository | ||
class DossiersResource: | ||
def __init__(self, _dossiersRepository: DossiersRepository): | ||
self._dossiersRepository = _dossiersRepository | ||
|
||
def on_get(self, req: Request, resp: Response) -> None: | ||
try: | ||
response = self._dossierRepository.fetch(req.params) | ||
dossiers = self._dossiersRepository.fetch(req.params["id"]) | ||
except ValueError as error: | ||
raise NotFoundError( | ||
f"No dossier records matching {str(req.params)} found." | ||
) from error | ||
resp.media = DossierRecordSchema().dump(response, many=True) | ||
resp.media = DossierRecordSchema().dump([dossiers], many=True) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from ebl.tests.factories.dossier import DossierRecordFactory | ||
from ebl.dossiers.application.dossiers_repository import DossiersRepository | ||
|
||
|
||
def test_fetch(dossiers_repository: DossiersRepository): | ||
dossier_record = DossierRecordFactory.build() | ||
dossiers_repository.create(dossier_record) | ||
dossiers_repository.create(DossierRecordFactory.build()) | ||
|
||
assert dossiers_repository.fetch(dossier_record.id) == dossier_record |
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,28 @@ | ||
import falcon | ||
import pytest | ||
|
||
from ebl.dossiers.domain.dossier_record import DossierRecord | ||
from ebl.tests.factories.dossier import ( | ||
DossierRecordFactory, | ||
) | ||
from ebl.dossiers.application.dossiers_repository import ( | ||
DossiersRepository, | ||
) | ||
from ebl.dossiers.infrastructure.mongo_dossiers_repository import ( | ||
DossierRecordSchema, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def dossier_record() -> DossierRecord: | ||
return DossierRecordFactory.build() | ||
|
||
|
||
def test_fetch_dossier_record_route( | ||
dossier_record, dossiers_repository: DossiersRepository, client | ||
) -> None: | ||
dossiers_repository.create(dossier_record) | ||
get_result = client.simulate_get("/dossiers", params={"id": dossier_record.id}) | ||
|
||
assert get_result.status == falcon.HTTP_OK | ||
assert get_result.json[0] == DossierRecordSchema().dump(dossier_record) |