Skip to content

Commit 023e8ba

Browse files
committed
Adiciona cidades
1 parent 9cf333e commit 023e8ba

5 files changed

Lines changed: 113 additions & 0 deletions

File tree

pynfe/data/MunIBGE/MunIBGE-UF15.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
1500305 Afuá
55
1500347 Água Azul do Norte
66
1500404 Alenquer
7+
1504752 Mojuí dos Campos
78
1500503 Almeirim
89
1500602 Altamira
910
1500701 Anajás

pynfe/data/MunIBGE/MunIBGE-UF42.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
4212403 Pedras Grandes
191191
4212502 Penha
192192
4212601 Peritiba
193+
4212650 Pescaria Brava
193194
4212700 Petrolândia
194195
4212809 Balneário Piçarras
195196
4212908 Pinhalzinho
@@ -291,3 +292,4 @@
291292
4219606 Xavantina
292293
4219705 Xaxim
293294
4219853 Zortéa
295+
4220000 Balneário Rincão

pynfe/data/MunIBGE/MunIBGE-UF43.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
4314472 Pinhal Grande
316316
4314498 Pinheirinho do Vale
317317
4314506 Pinheiro Machado
318+
4314548 Pinto Bandeira
318319
4314555 Pirapó
319320
4314605 Piratini
320321
4314704 Planalto

pynfe/data/MunIBGE/MunIBGE-UF50.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
5006002 Nova Alvorada do Sul
5656
5006200 Nova Andradina
5757
5006259 Novo Horizonte do Sul
58+
5006275 Paraíso das Águas
5859
5006309 Paranaíba
5960
5006358 Paranhos
6061
5006408 Pedro Gomes

tests/test_utils.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
obter_uf_por_codigo,
1313
formatar_decimal,
1414
remover_acentos,
15+
carregar_arquivo_municipios
1516
)
1617
from lxml import etree
1718
from pynfe.utils.descompactar import DescompactaGzip
@@ -241,5 +242,112 @@ def test_descompacta_string_gzip(self):
241242
self.assertEqual(resultado_str, esperado)
242243

243244

245+
class CidadesTestCase(unittest.TestCase):
246+
"""
247+
Testar quantidade de cidades por UF
248+
pelo arquivos MunIBGE-UFXX.txt
249+
250+
"""
251+
def test_quantidade_cidades_ac(self):
252+
self.assertEqual(len(carregar_arquivo_municipios(uf=12)), 22)
253+
254+
def test_quantidade_cidades_al(self):
255+
self.assertEqual(len(carregar_arquivo_municipios(uf=27)), 102)
256+
257+
def test_quantidade_cidades_ap(self):
258+
self.assertEqual(len(carregar_arquivo_municipios(uf=16)), 16)
259+
260+
def test_quantidade_cidades_am(self):
261+
self.assertEqual(len(carregar_arquivo_municipios(uf=13)), 62)
262+
263+
def test_quantidade_cidades_ba(self):
264+
self.assertEqual(len(carregar_arquivo_municipios(uf=29)), 417)
265+
266+
def test_quantidade_cidades_ce(self):
267+
self.assertEqual(len(carregar_arquivo_municipios(uf=23)), 184)
268+
269+
def test_quantidade_cidades_df(self):
270+
self.assertEqual(len(carregar_arquivo_municipios(uf=53)), 1)
271+
272+
def test_quantidade_cidades_es(self):
273+
self.assertEqual(len(carregar_arquivo_municipios(uf=32)), 78)
274+
275+
def test_quantidade_cidades_go(self):
276+
self.assertEqual(len(carregar_arquivo_municipios(uf=52)), 246)
277+
278+
def test_quantidade_cidades_ma(self):
279+
self.assertEqual(len(carregar_arquivo_municipios(uf=21)), 217)
280+
281+
def test_quantidade_cidades_mt(self):
282+
self.assertEqual(len(carregar_arquivo_municipios(uf=51)), 141)
283+
284+
def test_quantidade_cidades_ms(self):
285+
self.assertEqual(len(carregar_arquivo_municipios(uf=50)), 79)
286+
287+
def test_quantidade_cidades_mg(self):
288+
self.assertEqual(len(carregar_arquivo_municipios(uf=31)), 853)
289+
290+
def test_quantidade_cidades_pa(self):
291+
self.assertEqual(len(carregar_arquivo_municipios(uf=15)), 144)
292+
293+
def test_quantidade_cidades_pb(self):
294+
self.assertEqual(len(carregar_arquivo_municipios(uf=25)), 223)
295+
296+
def test_quantidade_cidades_pr(self):
297+
self.assertEqual(len(carregar_arquivo_municipios(uf=41)), 399)
298+
299+
def test_quantidade_cidades_pe(self):
300+
self.assertEqual(len(carregar_arquivo_municipios(uf=26)), 185)
301+
302+
def test_quantidade_cidades_pi(self):
303+
self.assertEqual(len(carregar_arquivo_municipios(uf=22)), 224)
304+
305+
def test_quantidade_cidades_rj(self):
306+
self.assertEqual(len(carregar_arquivo_municipios(uf=33)), 92)
307+
308+
def test_quantidade_cidades_rn(self):
309+
self.assertEqual(len(carregar_arquivo_municipios(uf=24)), 167)
310+
311+
def test_quantidade_cidades_rs(self):
312+
self.assertEqual(len(carregar_arquivo_municipios(uf=43)), 497)
313+
314+
def test_quantidade_cidades_ro(self):
315+
self.assertEqual(len(carregar_arquivo_municipios(uf=11)), 52)
316+
317+
def test_quantidade_cidades_rr(self):
318+
self.assertEqual(len(carregar_arquivo_municipios(uf=14)), 15)
319+
320+
def test_quantidade_cidades_sc(self):
321+
self.assertEqual(len(carregar_arquivo_municipios(uf=42)), 295)
322+
323+
def test_quantidade_cidades_sp(self):
324+
self.assertEqual(len(carregar_arquivo_municipios(uf=35)), 645)
325+
326+
def test_quantidade_cidades_se(self):
327+
self.assertEqual(len(carregar_arquivo_municipios(uf=28)), 75)
328+
329+
def test_quantidade_cidades_to(self):
330+
self.assertEqual(len(carregar_arquivo_municipios(uf=17)), 139)
331+
332+
def test_quantidade_total_cidades(self):
333+
"""
334+
Carregar todos os arquivos
335+
e verificar a quantidade total de cidades
336+
337+
"""
338+
total = 0
339+
lista_de_codigos_uf = [
340+
11, 12, 13, 14, 15, 16, 17, # Norte
341+
21, 22, 23, 24, 25, 26, 27, 28, 29, # Nordeste
342+
31, 32, 33, 35, # Sudeste
343+
41, 42, 43, # Sul
344+
50, 51, 52, 53 # Centro-Oeste
345+
]
346+
for uf in lista_de_codigos_uf:
347+
total += len(carregar_arquivo_municipios(uf=uf))
348+
349+
self.assertEqual(total, 5570)
350+
351+
244352
if __name__ == "__main__":
245353
unittest.main()

0 commit comments

Comments
 (0)