agentsclimarketplace

Test

Skill eduardo-lezama/intranet-dashboard/.windsurf.bak/skills/test

Usar al crear o modificar tests con pytestFrom its SKILL.md

Install
npx -y skills add eduardo-lezama/intranet-dashboard --skill test

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.1 KB, 812 tokens by cl100k_base, as published. Nobody here has run it

Cuándo usar esta skill

  • Al crear tests para código nuevo o existente
  • Cuando se pida "testear", "añadir tests", "verificar"
  • Después de arreglar un bug (test de regresión)

Contexto necesario antes de empezar

  1. Código a testear (leer y entender)
  2. Comportamiento esperado
  3. Casos edge a considerar
  4. Dependencias externas a mockear

Pasos

1. Verificar estructura de tests

Si no existe tests/, crear:

mkdir tests
touch tests/__init__.py
touch tests/conftest.py

2. Crear conftest.py (si no existe)

# tests/conftest.py
import pytest
from app import create_app


@pytest.fixture
def app():
    """Crear app en modo testing"""
    app = create_app('development')
    app.config['TESTING'] = True
    return app


@pytest.fixture
def client(app):
    """Cliente de test Flask"""
    return app.test_client()

3. Crear archivo de test

Nombrar: tests/test_[módulo].py

# tests/test_endpoints.py
def test_api_status_returns_ok(client):
    """GET /api/status debe retornar status ok"""
    response = client.get('/api/status')
    
    assert response.status_code == 200
    data = response.get_json()
    assert data['status'] == 'ok'

4. Mockear APIs externas

from unittest.mock import patch, Mock

def test_energy_client_handles_error(client):
    """Endpoint debe manejar errores del cliente"""
    with patch('blueprints.main.EnergyClient') as mock:
        mock.return_value.get_energy_summary.side_effect = Exception("API down")
        
        response = client.get('/api/energy')
        
        assert response.status_code == 500
        assert 'error' in response.get_json()

5. Ejecutar tests

pytest tests/ -v              # Todos
pytest tests/test_app.py -v   # Un archivo
pytest -k "test_api" -v       # Por nombre
pytest -x                     # Parar en primer fallo

<patrones_criticos> SIEMPRE:

  • Un assert principal por test
  • Nombres descriptivos: test_[qué]_[condición]_[resultado]
  • Mockear APIs externas (nunca llamar servicios reales)
  • Usar fixtures para setup repetitivo

NUNCA:

  • Tests que dependen de servicios externos reales
  • Tests que dependen del orden de ejecución
  • Hardcodear datos que deberían ser fixtures

PREFERENTEMENTE:

  • Tests pequeños y enfocados
  • Cubrir casos de error además de happy path
  • Documentar con docstring qué se está testeando </patrones_criticos>

Estructura de tests recomendada

tests/
├── __init__.py
├── conftest.py           # Fixtures compartidos
├── test_app.py           # Tests de la app Flask
├── test_endpoints.py     # Tests de endpoints API
├── test_energy_client.py # Tests del cliente Energy
├── test_mealie_client.py # Tests del cliente Mealie
└── test_pihole_client.py # Tests del cliente Pi-hole

Checklist de validación

  • Tests pasan: pytest tests/ -v
  • Tests son independientes entre sí
  • APIs externas mockeadas
  • Casos de error cubiertos
  • ruff check tests/ pasa

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,790. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.