Skip to content

Setup Test Environment for Data Manager Server

Stone Zhong edited this page Apr 20, 2021 · 5 revisions

Brief

Test is critical to keep the project in high quality. This article record how I setup test environment in my dev machine.

I created a test deployment and run all the test in that deployment.

Setup

# my mordor config is located at ~/dm/deployment_configs/home
export MORDOR_CONFIG_DIR=~/dm/deployment_configs/home

# initialize the host for mordoor
mordor -a init-hosot -o trentor

# deploy the code
mordor -a stage -p dm -s test --update-venv

# After you done with mordor stage, you can remove the link "current" and re-create it, do this, you do not need to stage every time you update the code!
ln -s /home/stonezhong/dm/DataManager/server current

Run tests

# run all tests
eae dm
python manage.py test

(dm-0.0.1) stonezhong@trentor ~/DATA_DISK/mordor/apps/dm/current $ python manage.py test 
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.................
----------------------------------------------------------------------
Ran 17 tests in 1.224s

OK
Destroying test database for alias 'default'...

You can also get the code coverage data:

python -m coverage run --source="." manage.py test
# Then run command below to generate report
python -m coverage html