Skip to content

Developing qbank locally

cjshawMIT edited this page Apr 28, 2017 · 6 revisions

Local development / testing

Installing Dependencies

Once you have your local environment set up (using either Docker containers or virtualenv is recommended), you need to install the project requirements:

pip install -r requirements.txt

Running qbank

After you've installed the dependencies, running qbank is as simple as:

python main.py

This will start the qbank server on port 8080. You can change the default port if needed by doing

python main.py <new port>

Like

python main.py 8888

You can then access the api via https, for example: https://localhost:8080/version.

For additional api endpoints and data on how to use them, please refer to the docs.

Testing

qbank uses pytest to check conformance with pep8 and the unit / functional tests.

Configuring qbank for Testing

To make sure the tests run correctly with authorization, you need to add a settings.py file in the project's root directory, with the following value:

AUTHZ_USER = "[email protected]"

When you switch to a production environment with authorization enabled, you need to update that value and keep it a secret.

Installing Test Dependencies

Test dependencies are located in test_requirements.txt and can be installed with:

pip install -r test_requirements.txt

Running Tests

You can run all the tests via:

pytest

To run only a subset or a specific test, you can do things like:

pytest tests/test_assessment.py
pytest tests/test_assessment.py::AnswerTypeTests
pytest tests/test_assessment.py::AnswerTypeTests::test_default_answer_genus_is_right_answer_when_not_specified

You can also include the -x flag to stop the tests on the first failure.

pytest -x