Tips

System dependencies

sqlserver (Microsoft Sql Server)

Debian:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
echo "deb https://packages.microsoft.com/debian/12/prod bookworm main" | sudo tee /etc/apt/sources.list.d/microsoft.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql18 mssql-tools18

mariadb (MariaDB or MySQL)

Debian:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

Quick start guide for development and testing

Install required system dependencies (see above).

Create Python virtual environment (example on Debian Linux):

python3 -m venv .venv       # Windows:  python -m venv .venv
source .venv/bin/activate   # Windows:  .\.venv\Scripts\activate
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt

Configure tests with a zut-tests.conf file (see example).

Start test SqlServer database using Docker:

docker run -d --rm --name zut-tests-sqlserver -e TZ=Europe/Paris -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=testmeZ0 -e MARIADB_DATABASE=test_zut -p 127.0.0.1:1433:1433 mcr.microsoft.com/mssql/server:2022-latest
docker exec -it zut-tests-sqlserver /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P testmeZ0 -No -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'TestZut') CREATE DATABASE TestZut"

Start test MariaDB database using Docker:

docker run -d --rm --name zut-tests-mariadb -e TZ=Europe/Paris -e MARIADB_ROOT_PASSWORD=testmeZ0 -e MARIADB_DATABASE=test_zut -p 127.0.0.1:3306:3306 mariadb

Start test PostgreSQL database using Docker:

docker run -d --rm --name zut-tests-postgresql -e TZ=Europe/Paris -e POSTGRES_PASSWORD=testmeZ0 -e POSTGRES_DB=test_zut -p 127.0.0.1:5432:5432 postgres

Start test Samba server using Docker:

mkdir -p $PWD/data/share
chmod 777 $PWD/data/share
docker run -d --rm --name zut-tests-samba -e TZ=Europe/Paris -e ACCOUNT_zut=testmeZ0 -e "SAMBA_VOLUME_CONFIG_shared_home=[tests]; path=/shares/tests; valid users = zut; guest ok = no; read only = no; browseable = yes" \
    -v $PWD/data/share:/shares/tests \
    -p 127.0.0.1:139:139 -p 127.0.0.1:137:137 -p 127.0.0.1:445:445 \
    ghcr.io/servercontainers/samba

Run tests:

python -m unittest

Install from a git repository

From a Git branch or tag (using https or ssh):

pip install git+https://gitlab.com/ipamo/zut.git@main#egg=zut
pip install git+ssh://git@gitlab.com/ipamo/zut.git@main#egg=zut

Clean repository

Using Powershell:

Get-ChildItem -Include __pycache__,build,*.egg-info -Recurse -force | Where-Object fullname -notlike "*\.venv\*" | Remove-Item -Force -Recurse

Using Linux shell:

find . \( -name __pycache__ -o -name build -o -name "*.egg-info" \) -not -path "./.venv/*" -exec rm -rf {} \;

View non-versionned files:

git ls-files -o -x .venv