diff options
Diffstat (limited to 'tests/server.py')
| -rw-r--r-- | tests/server.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/server.py b/tests/server.py index 46185a0..57fa120 100644 --- a/tests/server.py +++ b/tests/server.py @@ -76,6 +76,22 @@ SYNTHETIC = [ DROPPED_CEP = "00000099" +# The municipality a missing CEP would have belonged to, attached to the +# 404 for /25845000 below. The numbers are Areal/RJ's real ones: cep_ini is +# 25845001, one past the 25845000 the DNE publishes as the start of the +# range and that the route refuses, and the 118 CEPs are scattered over the +# ~4900 numbers up to cep_fim rather than filling them. +AREAL = { + "localidade": "Areal", + "uf": "RJ", + "estado": "Rio de Janeiro", + "regiao": "Sudeste", + "ibge": "3300225", + "cep_ini": "25845001", + "cep_fim": "25849899", + "ceps": 118, +} + LONG_STREET = "Avenida " + ("Muito Comprida " * 20) COUNTS = {} @@ -166,6 +182,32 @@ def route(path, query, hits): return 404, json_body( {"erro": "cep_nao_encontrado", "mensagem": "gone"} ), {} + if path == "/25845000": + return 404, json_body( + { + "erro": "cep_nao_encontrado", + "mensagem": "CEP não existe na base do DNE", + "faixa": AREAL, + } + ), {} + if path == "/25849900": + return 404, json_body( + { + "erro": "cep_nao_encontrado", + "mensagem": "CEP não existe na base do DNE", + } + ), {} + if path == "/25845002": + broken = dict(AREAL) + broken["cep_fim"] = "nope" + broken["ceps"] = "many" + return 404, json_body( + {"erro": "cep_nao_encontrado", "faixa": broken} + ), {} + if path == "/25845003": + return 404, json_body( + {"erro": "cep_nao_encontrado", "faixa": "Areal"} + ), {} if path == "/00000000": return 400, json_body( {"erro": "cep_invalido", "mensagem": "rejected by the API"} |