Skip to content

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 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 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

After

  • Write test_tx_history_generate_table() test.
Edited by Moul
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information