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

Available Tests

There are several test files that try to cover all use cases for qbank in the CLIx project.

test_assessment.py

Tests various generic aspects of the assessment api, including tests for non-CLIx question types.

test_asset_accessibility.py

Tests the various media accessibility traits, like altText, mediaDescription, vttFile and transcript files. On the authoring side, makes sure that can set, update, and remove each of those values. On the assessment-taking side, makes sure that each of those comes back in the requested language and in the right spot in the question markup.

test_drag_and_drop.py

Tests all aspects of authoring and taking drag-and-drop questions, including creation of zones, droppables, and targets. Also makes sure that the labels and names come back in the requested language.

test_logging.py

Tests the logging endpoints.

test_qti.py

Mostly tests that the upload of qti v2.1 zip files works for the supported question types. Also makes sure the XML returns correctly.

test_repository.py

Tests the saving and creation of media assets, as well as the streaming.

test_restful_items.py

Tests the api for creating and updating the supported question types via REST (instead of qti zip files).

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