feat: campo Ativo no cadastro e filtro de status na listagem de clientes
This commit is contained in:
@@ -436,6 +436,52 @@ def test_form_novo_preenche_codigo_sugerido(monkeypatch):
|
||||
assert 'value="000243"' in resposta.text
|
||||
|
||||
|
||||
def test_form_novo_ativo_pre_selecionado(monkeypatch):
|
||||
monkeypatch.setattr(router_clientes.db_clientes, "proximo_codigo_sugerido", lambda: "000243")
|
||||
resposta = client.get("/clientes/novo")
|
||||
assert resposta.status_code == 200
|
||||
assert '<option value="1" selected>Ativo</option>' in resposta.text
|
||||
|
||||
|
||||
def test_editar_cliente_ativo_zero_fica_selecionado(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
router_clientes.db_clientes,
|
||||
"obter_cliente",
|
||||
lambda cid: {**{c: "" for c in router_clientes.db_clientes.CAMPOS_CLIENTE}, "ID": cid, "ATIVO": 0},
|
||||
)
|
||||
resposta = client.get("/clientes/1/editar")
|
||||
assert resposta.status_code == 200
|
||||
assert '<option value="0" selected>Inativo</option>' in resposta.text
|
||||
|
||||
|
||||
def test_listar_clientes_tem_select_de_status(monkeypatch):
|
||||
monkeypatch.setattr(router_clientes.db_clientes, "listar_clientes", lambda **kwargs: [])
|
||||
monkeypatch.setattr(router_clientes.db_clientes, "contar_clientes", lambda **kwargs: 0)
|
||||
|
||||
resposta = client.get("/clientes")
|
||||
assert resposta.status_code == 200
|
||||
assert '<option value="ativos" selected>Ativos</option>' in resposta.text
|
||||
assert '<option value="inativos" >Desativados ou inativos</option>' in resposta.text
|
||||
assert '<option value="todos" >Todos</option>' in resposta.text
|
||||
|
||||
|
||||
def test_listar_clientes_status_preservado_nos_links_de_paginacao(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
router_clientes.db_clientes,
|
||||
"listar_clientes",
|
||||
lambda **kwargs: [
|
||||
{"ID": i, "CODIGO": f"{i:06d}", "RAZAO": f"Cliente {i}", "FANTASIA": f"C{i}", "CNPJ": "1"}
|
||||
for i in range(1, 6)
|
||||
],
|
||||
)
|
||||
monkeypatch.setattr(router_clientes.db_clientes, "contar_clientes", lambda **kwargs: 250)
|
||||
|
||||
resposta = client.get("/clientes?pagina=2&por_pagina=100&status=todos")
|
||||
assert resposta.status_code == 200
|
||||
assert "status=todos" in resposta.text
|
||||
assert '<option value="todos" selected>Todos</option>' in resposta.text
|
||||
|
||||
|
||||
def test_detalhe_cliente_mostra_formulario_de_edicao_de_contato(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
router_clientes.db_clientes,
|
||||
|
||||
Reference in New Issue
Block a user