Skip to content

Som-Energia/SomCommonSkills / erp-test

erp-test

Verified

Executa tests de mòduls Odoo/Som Energia utilitzant destral. Automatitza: verificar contenidors, activar pyenv, executar dodestral. Trigger: Quan necessites executar tests d'un mòdul Odoo amb destral.

When to Use

Utilitza aquesta skill quan:

  • Necessites executar tests d'un mòdul Odoo del projecte
  • Vols automatitzar el workflow de testing local
  • Estàs desenvolupant un mòdul i necessites TDD

Configuració Requerida

Aquesta skill requereix:

  1. Contenidors Docker: Només PostgreSQL, MongoDB, Redis (Odoo corre al host)
  2. pyenv: Entorn virtual amb nom erp (pyenv virtualenv erp)
  3. Odoo instal·lat al host: A /home/oriol/somenergia/src/erp/server/bin

Workflow

Pas 1: Verificar Contenidors (només BBDD)

docker ps --format "{{.Names}}" | grep -E "postgres|redis|mongo"

Contenidors esperats:

  • PostgreSQL (src_db_1)
  • MongoDB (src_mongo_1)
  • Redis (src_redis_1)
  • Odoo NO està a Docker — corre al host

Pas 2: Activar pyenv

pyenv activate erp

O si està configurat amb pyenv-virtualenv:

source $(pyenv which activate)

Pas 3: Variables d'Entorn

Configurar segons el workflow de GitHub Actions:

export PYTHONPATH=/home/oriol/somenergia/src/erp/server/bin:/home/oriol/somenergia/src/erp/server/bin/addons
export OPENERP_PRICE_ACCURACY=6
export OORQ_ASYNC=False
export OPENERP_DB_HOST=localhost
export OPENERP_DB_USER=erp
export OPENERP_DB_PASSWORD=erp
export OPENERP_MONGODB_HOST=localhost
export OPENERP_REDIS_URL=redis://localhost:6379/0

Pas 4: Executar destral

dodestral <database> -m <module_name>

Exemple:

dodestral test_som_polissa -m som_polissa

O amb opcions adicionals:

destral --report-coverage test_som_polissa -m som_polissa

Usage

Execució Bàsica

# Activar entorn i executar tests
pyenv activate erp && dodestral test_db -m som_polissa

Script Wrapper Recomanat

Crear un script a ~/bin/run-erp-test:

#!/bin/bash
set -e

MODULE=${1:-som_polissa}
DB_NAME=${2:-test_erp}

# Verificar contenidors
echo "=== Verificant contenidors ==="
docker ps --format "{{.Names}}" | grep -E "postgres|redis|mongo" || {
    echo "ERROR: Contenidors no corrent. Executa 'docker-compose up -d' primer."
    exit 1
}

# Activar pyenv
echo "=== Activant entorn erp ==="
eval "$(pyenv init -)"
pyenv activate erp

# Variables
export PYTHONPATH=/home/oriol/somenergia/src/erp/server/bin:/home/oriol/somenergia/src/erp/server/bin/addons
export OPENERP_PRICE_ACCURACY=6
export OORQ_ASYNC=False
export OPENERP_DB_HOST=localhost
export OPENERP_DB_USER=erp
export OPENERP_DB_PASSWORD=erp
export OPENERP_MONGODB_HOST=localhost
export OPENERP_REDIS_URL=redis://localhost:6379/0

# Executar tests
echo "=== Executant tests de $MODULE ==="
dodestral $DB_NAME -m $MODULE

Errors Comuns

ErrorCausaSolució
destral: command not foundpyenv no activatpyenv activate erp
Connection refused to localhost:5432PostgreSQL no correntdocker-compose up -d (al directori de BBDDs)
Connection refused to localhost:27017MongoDB no correntdocker-compose up -d
Connection refused to localhost:6379Redis no correntdocker-compose up -d
Database does not existDB no creadadestral la crea automàticament
timeoutTests molt lentsEls tests d'Odoo poden trigar 10+ min

Integració amb SDD

Aquesta skill s'utilitza a les fases:

  • sdd-apply: Per verificar que el codi implementat passa els tests
  • sdd-verify: Per validar contra specs

El test runner detectat és: dodestral (custom Odoo test runner)

finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall