feat(tests): adicionar testes para filtro E_CONSULTOR e RankingStore

- Adicionar campo e_consultor nos testes de processar_ranking
- Adicionar testes de inserção com E_CONSULTOR no ranking_repository
- Criar test_ranking_store.py com testes de filtro ativo/inativo
- Garantir que filtros de ativo/inativo só afetam consultores
This commit is contained in:
Frederico Castro
2025-12-30 23:32:02 -03:00
parent 3558a4b6ca
commit 0a0a47ecc4
3 changed files with 149 additions and 5 deletions

View File

@@ -0,0 +1,120 @@
import pytest
from src.infrastructure.ranking_store import RankingStore, RankingEntry
@pytest.fixture
def store():
return RankingStore()
@pytest.fixture
def entries_com_consultores_e_nao_consultores():
return [
RankingEntry(
id_pessoa=1,
nome="Consultor Ativo",
posicao=1,
pontuacao_total=500,
bloco_a=200,
bloco_b=0,
bloco_c=150,
bloco_d=100,
bloco_e=50,
ativo=True,
e_consultor=True,
anos_atuacao=5.0,
detalhes={},
),
RankingEntry(
id_pessoa=2,
nome="Consultor Inativo",
posicao=2,
pontuacao_total=400,
bloco_a=200,
bloco_b=0,
bloco_c=100,
bloco_d=50,
bloco_e=50,
ativo=False,
e_consultor=True,
anos_atuacao=3.0,
detalhes={},
),
RankingEntry(
id_pessoa=3,
nome="Nao Consultor (Coordenador)",
posicao=3,
pontuacao_total=300,
bloco_a=250,
bloco_b=0,
bloco_c=0,
bloco_d=50,
bloco_e=0,
ativo=False,
e_consultor=False,
anos_atuacao=2.0,
detalhes={},
),
]
@pytest.mark.asyncio
async def test_total_sem_filtro_traz_todos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
assert store.total() == 3
@pytest.mark.asyncio
async def test_total_filtro_ativo_somente_consultores_ativos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
assert store.total(filtro_ativo=True) == 1
@pytest.mark.asyncio
async def test_total_filtro_inativo_somente_consultores_inativos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
assert store.total(filtro_ativo=False) == 1
@pytest.mark.asyncio
async def test_get_page_filtro_ativo_somente_consultores_ativos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
total, entries = store.get_page(page=1, size=10, filtro_ativo=True)
assert total == 1
ids = [e.id_pessoa for e in entries]
assert 1 in ids
assert 2 not in ids
assert 3 not in ids
@pytest.mark.asyncio
async def test_get_page_filtro_inativo_somente_consultores_inativos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
total, entries = store.get_page(page=1, size=10, filtro_ativo=False)
assert total == 1
ids = [e.id_pessoa for e in entries]
assert 2 in ids
assert 1 not in ids
assert 3 not in ids
@pytest.mark.asyncio
async def test_get_slice_filtro_ativo_somente_consultores_ativos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
total, entries = store.get_slice(offset=0, limit=10, filtro_ativo=True)
assert total == 1
ids = [e.id_pessoa for e in entries]
assert 1 in ids
assert 2 not in ids
assert 3 not in ids
@pytest.mark.asyncio
async def test_get_page_sem_filtro_traz_todos(store, entries_com_consultores_e_nao_consultores):
await store.set_entries(entries_com_consultores_e_nao_consultores)
total, entries = store.get_page(page=1, size=10)
assert total == 3
ids = [e.id_pessoa for e in entries]
assert 1 in ids
assert 2 in ids
assert 3 in ids