Skip to main content

This is the SG_Test_Env Project

Project description

Python test Environment

@Swissglider

short description

This image creates the base image for the Pythontest Environment Class SGPytest for run tests against Source Code and runs unittest

how to install (only this makes sense ;-))

  • the Project to test (with setup.py etc..) are in: ~/developer/project1
docker run -d --name sg_test_env -e TZ=Europe/Zurich -p 80:8888 -v ~/developer/project1:/data -w /app swissglider/sg_test_env:latest
docker exec -it sg_test_env tail -f /tmp/uwsgi.log
docker exec -it sg_test_env bash

For other reasons (debugging / logs)

From Docker Hub

docker run -it --rm -p 80:8888 -e TZ=Europe/Zurich -w /app swissglider/sg_test_env:latest /start.sh

# or

docker run -d --name sg_test_env -p 80:8888 -e TZ=Europe/Zurich -w /app swissglider/sg_test_env:latest
docker exec -it sg_test_env bash
docker exec -it sg_test_env tail -f /tmp/uwsgi.log

From Github

docker build -t sg_test_env_i https://raw.githubusercontent.com/swissglider/SG_Test_Env/master/Dockerfile
docker -it --rm -p 80:8888 -e TZ=Europe/Zurich sg_test_env_i /start.sh

# or

docker build -t sg_test_env_i https://raw.githubusercontent.com/swissglider/SG_Test_Env/master/Dockerfile
docker run -d --name sg_test_env -p 80:8888 -e TZ=Europe/Zurich -w /app sg_test_env_i
docker exec -it sg_test_env bash
docker exec -it sg_test_env tail -f /tmp/uwsgi.log

From Dockerfile

docker build -t sg_test_env_i -f Dockerfile .
docker -it --rm -p 80:8888 -e TZ=Europe/Zurich sg_test_env_i /start.sh
docker -it --rm -p 80:8888 -e TZ=Europe/Zurich sg_test_env_i bash

# or

docker build -t sg_test_env_i -f Dockerfile .
docker run -d --name sg_test_env -p 80:8888 -e TZ=Europe/Zurich -w /app sg_test_env_i
docker exec -it sg_test_env bash
docker exec -it sg_test_env tail -f /tmp/uwsgi.log

For debugging flask

docker run -d --name sg_test_env -e TZ=Europe/Zurich -p 8888:8888 -v ~/developer/SG_Test_Env:/data -e FLASK_APP=main.py -e FLASK_DEBUG=1 swissglider/sg_test_env:latest bash -c "while true ; do sleep 10 ; done"
docker exec -it sg_test_env bash
flask run --host=0.0.0.0 --port=8888


docker run -it --rm -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env/:/app -w /app swissglider/sg_test_env:test sh install_script/sg_flask.sh
docker run -it --rm -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env/:/app -w /app swissglider/sg_test_env:test sh install_script/sg_clean.sh

Install it for test in test docker python

docker run -it --rm --name sg_test_env -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env:/data -v ~/developer/SG_Test_Env:/app -w /data python:3.6.6 sh sg_flask.sh

docker run -it --rm --name sg_test_env -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env:/data -v ~/developer/SG_Test_Env -w /data python:3.6.6 bash

# Clean environment:
sh ./install_script/sg_clean.ch

# Test Pytest standalone - 1:
 pytest testing src --html=/data/src/sg_pytest/webapp/static/test.html --cov=src --cov-report=html:/data/src/sg_pytest/webapp/static/cov

# Test Pytest standalone - 2:
docker run -it --rm --name sg_test_env -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env:/data -v ~/developer/SG_Test_Env:/app -w /data python bash
pip install pytest
pip install pytest-cov
pip install pytest-html
pip install -e .
pytest --html=src/sg_pytest/webapp/static/test.html --cov --cov-report=html:src/sg_pytest/webapp/static/cov/ -s -vv

# Test setup.py test standalone - 3:
docker run -it --rm --name sg_test_env -e TZ=Europe/Zurich -p 80:80 -v ~/developer/SG_Test_Env:/data -v ~/developer/SG_Test_Env:/app -w /data python:3.6.5 bash
python setup.py test
sh sg_clean.sh


docker run -it --rm --name sg_test_env -e TZ=Europe/Zurich -v ~/developer/SG_Test_Env:/app -w /app python:3.6.5 bash
python setup.py test
sh ./install_script sg_clean.sh

SG_Test_Env Tests

# standalone
docker run -it --rm -e TZ=Europe/Zurich -w /app swissglider/sg_test_env:test python setup.py test

# with own app (wiht setup.py and tests etc)
docker run -it --rm -e TZ=Europe/Zurich -v ~/developer/SG_Test_Env:/app -w /app swissglider/sg_test_env:test bash
python setup.py test

# with access to static dir to get html output
docker run -it --rm -e TZ=Europe/Zurich -v ~/developer/static:/static -w /app swissglider/sg_test_env:test bash
python setup.py test

# with own test data 
docker run -it --rm -e TZ=Europe/Zurich -v ~/developer/test_data:/data -w /app swissglider/sg_test_env:test bash
python setup.py test

Directory architecture - Volumes

  • code

    • setup.py
    • setup.cfg
    • README.md
    • plugin_packages.txt
    • requirements.txt
    • sg_pytest.ini
    • test_requirements.txt
    • src (source Directory)
    • test (test files)
  • tmp_home

    • .pypirc

samples see

How to use it test framework

How to build

see howto Github build pypi

.pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository: https://pypi.python.org/pypi
username: YOUR_USERNAME_HERE
password: YOUR_PASSWORD_HERE

[pypitest]
repository: https://testpypi.python.org/pypi
username: YOUR_USERNAME_HERE
password: YOUR_PASSWORD_HERE

Open

  • make pypi
  • clean in web gui

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sg-test-env, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size sg_test_env-0.0.1.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page