-
Notifications
You must be signed in to change notification settings - Fork 0
TT-352 create v2 read activites flask endpoint #324
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
TT-352 create v2 read activites flask endpoint #324
Conversation
…read-activites-flask-endpoint
| import json | ||
| import typing | ||
|
|
||
|
|
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.
Siempre deben quedar dos líneas entre los imports y las clases o funciones de acuerdo a PEP 8. Creo que estaba bien
| if test_config is not None: | ||
| app.config.from_mapping(test_config) | ||
|
|
||
| ns_activities = Namespace('activities', description='Endpoint for activities') |
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.
con el prefijo ns_ te refieres a que es un namespace? capaz es mejor cambiar el nombre a activities_namespace
|
|
||
| class Activities(Resource): | ||
| def get(self): | ||
| activities_dto = use_cases.get_list_activities() |
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.
porqué el sufijo _dto?
| class Activity(Resource): | ||
| def get(self, activity_id: str): | ||
| try: | ||
| activities_dto = use_cases.get_activity_by_id(activity_id) |
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.
igual aquí
…itivies from JSON file
| yield client | ||
|
|
||
|
|
||
| def test__activities_class__uses_the_get_activities_use_case__to_retrieve_activities(client: FlaskClient, |
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.
Me gusta un montón el typing en el test
|
|
||
| def test__activities_class__uses_the_get_activities_use_case__to_retrieve_activities(client: FlaskClient, | ||
| mocker: MockFixture): | ||
| use_cases.get_list_activities = mocker.Mock(return_value=[]) |
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.
esto se hace con mocker.patch en lugar de reemplazar el valor real de get_list_activities
| yield client | ||
|
|
||
|
|
||
| def test__activities_class__uses_the_get_activities_use_case__to_retrieve_activities(client: FlaskClient, |
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.
El nombre de esta prueba dice: test__activities_class. Pero no estamos probando el activities class, estamos probando el endpoint de /activities. Entonces, este test no es un test unitario es un test de API y habría que ponerle en la correspondiente carpeta
| assert [] == json_data | ||
|
|
||
|
|
||
| def test__activity_class__returns_an_activity__when_activity_matches_its_id(client: FlaskClient, mocker: MockFixture): |
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.
igual que el anterior
| assert fake_activity == json.loads(response.data) | ||
|
|
||
|
|
||
| def test__activity_class__returns_an_activity__when_no_activity_matches_its_id(client: FlaskClient, |
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.
igual que el anterior
| fake = Faker() | ||
|
|
||
|
|
||
| def test__get_list_activities_function__uses_the_activities_service__to_retrieve_activities(mocker: MockFixture): |
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.
estos tests están perfectos
|
|
||
| class Activities(Resource): | ||
| def get(self): | ||
| activity_json = ActivitiesJsonDao(JSON_PATH) |
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.
Este código está duplicado con la línea 21
|
Kudos, SonarCloud Quality Gate passed!
|








Description
In this pull request, use cases and endpoints were created using flask to access activity data from a JSON file, according to the new backend architecture for the Time Tracker project.
The following image shows the new backend architecture.