Skip to content

Conversation

EliuX
Copy link
Contributor

@EliuX EliuX commented Mar 13, 2020

This PR:

  • Upgrades pytest to version 5.2.0, so we can use pytest-mock.
  • Tries out a mock in time_enties_namespace_test.py
  • Add support for configurations. By default it works with time_tracker_api.config.DefaultConfig.
  • Creates a configuration for a whatever database that can be taken as an example of what the access to any database should look like in a design/architecture that can be extensible.
  • whatever_repository.py how any database implementation (MongoDB, SQL databases, etc.) can be easily hooked using a generic Repository pattern.

In addition, I added a refactoring of the API models for what we thought would be a better naming system.

@@ -0,0 +1,14 @@
from flask import json

def test_list_should_return_empty_array(mocker, client):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have type hints here?
Also, check the name of the file, I think It should be 'time_entries_namespace_test' or why not just 'time_entries_test' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

init_app(flask_app)

return flask_app


def init_app_config(app, config_path, config_data=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have type hints here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

RepositoryModel = None


def init_app(app: Flask) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call this function 'init_database' directly ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some sort of standard that some objects like the APIs in flask Restplus have a function called init_app so they take the Flask app as a parameter and they do whatever initialization logic they need to be ready to be used by that app. So whatever module or package you add if you want to make it like pluggable to Flask this is pretty much the way to go

@EliuX EliuX force-pushed the feature/Create-configuration-and-database-routing#23 branch 2 times, most recently from 1c2fb43 to ee9b4b7 Compare March 16, 2020 17:24
@EliuX EliuX force-pushed the feature/Create-configuration-and-database-routing#23 branch from ee9b4b7 to ad77389 Compare March 16, 2020 19:07
@Angeluz-07 Angeluz-07 merged commit ba0ad4d into master Mar 16, 2020
@EliuX EliuX deleted the feature/Create-configuration-and-database-routing#23 branch March 16, 2020 20:36
@EliuX EliuX self-assigned this Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants