summaryrefslogtreecommitdiffstats
path: root/tests/helper
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-27 20:38:27 -0300
committerMurilo Ijanc <[email protected]>2026-07-27 20:38:27 -0300
commit399eac351b1bc29d5047dbac96486c281be1b05c (patch)
tree81151d5bf139f07096a8f38313d64482250163c2 /tests/helper
parent11d49bc25eb1643f1b742f9527212d8781f2e0de (diff)
downloadr-main.tar.gz
Report the municipality a missing CEP would have belonged toHEADv0.2.0main
A CEP that fails a lookup is rarely a random number: it is usually someone who knows the city and guessed, and the classic guess is the -000 that 957 municipalities never received. The API now answers those 404s with a faixa naming the municipality that owns the band the number fell into, which is the difference between telling a user "invalid CEP" and "no such CEP in Areal/RJ". It is context for an error and never an address, so it rides on the cepis_not_found condition instead of turning the failure into a success, and cep_ini/cep_fim are the endpoints that exist rather than the range the Correios publish - the interval between them is sparse, which is what ceps counts. Parsing is deliberately unable to signal: a faixa that is null, an array, a string or half a body leaves a clean not-found behind, because the caller asked for the CEP, not for the decoration on its absence.
Diffstat (limited to 'tests/helper')
-rw-r--r--tests/helper/utils.R11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/helper/utils.R b/tests/helper/utils.R
index 3c24a2f..94a15ff 100644
--- a/tests/helper/utils.R
+++ b/tests/helper/utils.R
@@ -16,6 +16,17 @@ SE_ADDRESS <- list(
siafi = "7107"
)
+AREAL_FAIXA <- list(
+ localidade = "Areal",
+ uf = "RJ",
+ estado = "Rio de Janeiro",
+ regiao = "Sudeste",
+ ibge = "3300225",
+ cep_ini = "25845001",
+ cep_fim = "25849899",
+ ceps = 118L
+)
+
CSV_HEADER <- paste0(
"cep,logradouro,complemento,unidade,bairro,localidade,uf,estado,regiao,",
"ibge,gia,ddd,siafi"