# Testing ## Requirements * Install `Tox` $ pip install tox * MySQL instance with database migrations applied (refer to quick start guide) $ export TEST_DB_URI=mysql://:@:/ ### PEP8 style checks $ tox -e pep8 ### Functional testing $ tox -e py35-functional Pros: * lightweight (controllers and DB models testing) * no OpenStack required * no IronFunctions required Cons: * MySQL server required * OpenStack authentication is not tested * IronFunctions API stubbed with fake implementation ### Integration tests The following env variables are required: * TEST_DB_URI - similar to functional tests, database endpoint * FUNCTIONS_API_URL - IronFunctions API URL (default value - `http://localhost:8080/v1`) * OS_AUTH_URL - OpenStack Identity endpoint * OS_PROJECT_NAME - OpenStack user-specific project name * OS_USERNAME - OpenStack user name * OS_PASSWORD - OpenStack user user password ```bash export TEST_DB_URI=mysql://:@:/ export FUNCTIONS_API_URL=://:/ export OS_AUTH_URL=://:/ export OS_PROJECT_NAME= export OS_USERNAME= export OS_PASSWORD= tox -epy35-integration ``` ### Testing: Docker-build The following operations are performed: * builds an image * deletes all artifacts (Python3.5 image and recently built image) ```bash export DOCKER_HOST=tcp://:> export TEST_DB_URI=mysql://:@:/ export FUNCTIONS_API_URL=://:/ export OS_AUTH_URL=://:/ tox -e docker-build ``` ### Testing Docker-full The following operations are performed: * build container from source code * run container with exposed ports * request Swagger API doc to see if API is responsive * destroy running container ```bash export DOCKER_HOST=tcp://:> export TEST_DB_URI=mysql://:@:/ export FUNCTIONS_API_URL=://:/ export OS_AUTH_URL=://:/ tox -e docker-full ``` ### Coverage regression testing $ tox -e py35-functional-regression ### Static code analysis with Bandit $ tox -e bandit