Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify api_fake_data's api_handler to be lazy
Previously api_handler function returned a lambda, that could be used as a decorator and would return fake or real function, depending on a global variable. The decision was made at import time. This made it very difficult to test decorated functions behaviour, since these functions were decorated away before there was any chance to mock config or global variable. With this commit api_handler returns a decorator, that, when applied, returns a function, that proxies calls to fake or real api function, depending on global variable. This consequently means there will be an extra function call for every request. However this would potentially allow us to switch behaviour from/to fake functions on the fly. This commit also restores fake decorators around health API functions.
- Loading branch information
Showing
4 changed files
with
41 additions
and
9 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