Make Click context optional to be able to call functions from an external module
## Problem Since Click migration (v0.7.0), It is not possible to use a function which internally make a request. For external usage and tests without Click is not possible. `EndPoint` class is coupled with Click context `pass_context` for custom endpoint or GTEST usage for BMA api string generation. ## Would allow - Write tests which requires requests is not possible (most of the tests) - @tuxmain to use the transaction functions for [ĞMixer](https://git.duniter.org/tuxmain/gmixer-py) and other projects to take advantages of Silkaj code. ## Solution In `EndPoint` class: - Use `RuntimeError` to detect that there is no Click context in case Click is installed and loaded - Use [`ModuleNotFoundError`](https://docs.python.org/3/library/exceptions.html#ModuleNotFoundError) in case Click is not installed - Previous point requires Python ≥ 3.6, and I didn’t found a way to import it with `__future__` for Python 3.5 support. - To keep Python 3.5 support, I can just check for general exception for now. And, when Silkaj will drop Python 3.5, we could add back `ModuleNotFoundError` exception. ## Test - [x] Test `EndPoint().BMA_ENDPOINT` with click context - [x] Test `EndPoint().BMA_ENDPOINT` without click context - [ ] [Figure out how to test a singleton function](https://stackoverflow.com/questions/43619748/destroying-a-singleton-object-in-python/43620075#43620075) - [x] Test with Python 3.5: Not found how to simulate missing module ## After - [ ] Write `test_tx_history_generate_table()` test.
issue