Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 1.62 KB

HACKING.md

File metadata and controls

58 lines (40 loc) · 1.62 KB

Hacking

Start with extending API functionality and use it in your CLI commands - IOW do not put too much logic into the CLI commands.

Set up

  1. you need pylint and flake8 which makes sure you follow coding style

  2. you might consider installing GNU/make which is used to simplify developers workflow - there is Makefile including the steps for checking code style and running tests

  3. tests are written in python.unittest to avoid unnecessary dependencies and are stored in the directory test/

  4. all development dependencies are tracked in the file dev-requirements.txt and can be installed with the following command

pip install -r dev-requirements.txt

Workflow

  1. Do your changes

  2. Run linters - either make lint or

pylint --rcfile=.pylintrc sap
PYTHONPATH=$(pwd):$PYTHONPATH pylint --rcfile=.pylintrc bin/sapcli
flake8 --config=.flake8 sap
PYTHONPATH=$(pwd):$PYTHONPATH flake8 --config=.flake8 bin/sapcli
  1. Run tests - either make test or
python -m unittest discover -b -v -s test/unit

You can also test subset (or single test case) by providing test case name pattern:

python -m unittest discover -b -v -s test/unit -k test-name-pattern
  1. Check code coverage - run either make report-coverage or
coverage run -m unittest discover -b -v -s test/unit
coverage report bin/sapcli $(find sap -type f -name '*.py')

You can also use html instead of run which will create the report at the path SOURCE_CODE_DIR/htmlcov/index.html. (Of course, the convenience make target exists - report-coverage-html).