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:
@@ -182,3 +182,27 @@ def test_contar_para_exportacao_com_filtros(repo, oracle_client):
|
||||
assert params["ativo"] == "S"
|
||||
assert params["selo_0"] == "EVENTO"
|
||||
assert params["selo_1"] == "PROJ"
|
||||
|
||||
|
||||
def test_filtro_ativo_filtra_apenas_consultores(repo, oracle_client):
|
||||
oracle_client.executar_query.return_value = [{"TOTAL": 100}]
|
||||
|
||||
repo.contar_total(filtro_ativo=True)
|
||||
|
||||
call_args = oracle_client.executar_query.call_args
|
||||
query = call_args[0][0]
|
||||
assert "E_CONSULTOR = 'S'" in query
|
||||
assert "ATIVO = :ativo" in query
|
||||
|
||||
|
||||
def test_filtro_ativo_false_filtra_apenas_consultores(repo, oracle_client):
|
||||
oracle_client.executar_query.return_value = [{"TOTAL": 100}]
|
||||
|
||||
repo.contar_total(filtro_ativo=False)
|
||||
|
||||
call_args = oracle_client.executar_query.call_args
|
||||
query = call_args[0][0]
|
||||
assert "E_CONSULTOR = 'S'" in query
|
||||
assert "ATIVO = :ativo" in query
|
||||
params = call_args[0][1]
|
||||
assert params["ativo"] == "N"
|
||||
|
||||
120
backend/tests/infrastructure/test_ranking_store.py
Normal file
120
backend/tests/infrastructure/test_ranking_store.py
Normal 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
|
||||
Reference in New Issue
Block a user