xivo-lib-python
=========
[![Build Status](https://travis-ci.org/xivo-pbx/xivo-lib-python.png?branch=master)](https://travis-ci.org/xivo-pbx/xivo-lib-python)

xivo-lib-python is a common library used by various other services in XiVO


Running unit tests
------------------

```
apt-get install libpq-dev python-dev libffi-dev libyaml-dev python3-dev
pip install tox
tox --recreate -e py27
```

or

```
apt-get install libpq-dev python-dev libffi-dev libyaml-dev python3-dev
pip install -U -r requirements.txt
pip install -U -r test-requirements.txt
nosetests
```


Running integration tests
-------------------------

You need Docker installed.

First install the requirements :
```
cd integration_tests
pip install -U -r test-requirements.txt
```
Then you can test python 2 (you need python 2.7):
```
make clone test-setup-python2
make test
```
and/or python 3 (you need your python3 version to be at least 3.7)
```
make clone test-setup-python3
make test
```

If your python versions aren't compliant, you should use docker instead, and mount at least your project directory inside 
(we mount $HOME by default, beware if it is installed elsewhere)
Warning : this command will run all the python2 and python3 tests at once.
```
cd integration_tests
make clone
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro \
--network host \
-v /etc/shadow:/etc/shadow:ro \
-v "$HOME":"$HOME" \
-w "`pwd`" xivoxc/debian-builder:2021.13.latestdev /bin/bash -c "virtualenv /tmp/env2; \
source /tmp/env2/bin/activate; \
pip install pip==20.3.4; \
pip install -r test-requirements.txt; \
make test-setup-python2; \
make test; \
deactivate; \
python3 -m venv /tmp/venv3; \
source /tmp/venv3/bin/activate; \
pip install pip==20.3.4; \
pip install -r test-requirements.txt; \
make test-setup-python3; \
make test"
```