Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_es_referenciacatastral.doctest
blob: 94610ee88c9ba2fb229ed31f1314da8cc788cf53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
test_es_referenciacatastral.doctest - more detailed doctests

Copyright (C) 2016 David García Garzón
Copyright (C) 2015-2017 Arthur de Jong

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA


This file contains more detailed doctests for the
stdnum.es.referenciacatastral module.

>>> from stdnum.es import referenciacatastral
>>> from stdnum.exceptions import *


The parcel digits are structured differently for urban, non-urban or special
(infrastructure) cases:

* Urban states
    * 7 digits: (numeric) block sequence within cartographic sheet,
        and parcel sequence within the block.
    * 7 digits: (alphanum) cartographic sheet where the block centroid is.

* Non-urban states:
    * 2 digits: (numeric) Province or more exactly, ministerial delegation
    * 3 digits: (numeric) Municipality
    * 1 digits: (letter) Sector
    * 3 digits: (numeric) Polygon
    * 5 digits: (numeric) Parcel

* Special states:
    * BICE code: (2 digits, a number and a letter)
        * Energy infrastructure
            * 1E: Thermal power plant
            * 1G: Regasification terminal
            * 1R: Oil refinery
            * 1N: Nuclear power plant
            * 1H: Hydro power plant
        * Hydro
            * 2P: Dam
        * Roads and highways
            * 3A: Tolled highway
            * 3C: Tolled road
            * 3T: Tolled tunnel
        * Ports and airports
            * 4A: Airports
            * 4P: Commercial ports
    * Province (major if many) (2 digits)
    * Municipality (3 digits)
    * Scope (1 letter)
        * E: National
        * A: Autonomous Community
        * P: Province
        * M: Municipality
    * Number of municipalities it extends (2 digits, numbers)
    * Abbreviated denomination (4 digits, letters)

An online validator can be found at
https://www1.sedecatastro.gob.es/CYCBienInmueble/OVCBusqueda.aspx


This is a constructed example of a Referencia Catastral with an Ñ in it. It
seems that unicode literals do not work so we are escaping Ñ.

>>> referenciacatastral.calc_check_digits('9872023 ÑH5797S 0001')
'WP'
>>> referenciacatastral.calc_check_digits(u'9872023 \xd1H5797S 0001')
'WP'
>>> referenciacatastral.validate('9872023 ÑH5797S 0001 WP') == '9872023ÑH5797S0001WP'
True
>>> referenciacatastral.validate(u'9872023 \xd1H5797S 0001 WP') == u'9872023\xd1H5797S0001WP'
True


These have been found online and should all be valid numbers.

>>> numbers = '''
...
... 000100100QE45D0001GA
... 000100100TH44D0001GX
... 000700100UJ13C0001XY
... 0014001QD4901S0001LP
... 001700100QC04D0001AF
... 002100100QD03C0001HH
... 0307813QD3100N0001LW
... 0376902QE3607N0001UM
... 0412501QD0301S0001BQ
... 0426012TJ3502N0001SQ
... 0474001QE5307C0033DW
... 0474001QE5307C0060IB
... 0474001QE5307C0067GR
... 0474001QE5307C0149YK
... 0553304TK9405S0001GR
... 06011A012002450000QE
... 06011A045000920000QX
... 06016A012090090000ZI
... 06051A005000200000ZJ
... 06060A040001360000XM
... 06063A002000200001SL
... 06063A015000110000AX
... 06074A005005560000BR
... 06079A002002810000JX
... 06080A504000390000II
... 06080A507000270000IK
... 06083A045001460000ZM
... 06083A136002390000UH
... 06084A508000290000QT
... 06084A511000950000QL
... 06085A009000130000YK
... 06086A023000710000PG
... 06092A010090070000XY
... 06105A014002400000QA
... 06127A011000890000LG
... 06150A022002960000YK
... 06151A008000450000PE
... 06153A002000420000KQ
... 06154A016090110000XD
... 06160A030009840000AJ
... 06162A009000770000LK
... 06900A228000090000EB
... 06900A228000110000EA
... 06900A230000050000EG
... 0736601QE2503N0002XI
... 0786418PD6508N0001GB
... 0791405PD6509S0001RX
... 0811056TJ8201S0001QF
... 0847501PE8504N0001EF
... 0895009TK5309N0001DA
... 0939216PD5603N0001BB
... 0989801QC2308N0001LY
... 10010A012005070000SA
... 10033A017000040000AH
... 10036A001002140000MU
... 10042A005090420000SX
... 10063A006000030000EW
... 10083A002030290000DX
... 10103A002002490000IE
... 10105A007004020000HQ
... 10118A004030320000PY
... 10122A032090100000FH
... 10134A009000010000RY
... 10149A011090100000YZ
... 10178A034090180000JE
... 1087910TK7118N0001FS
... 10900A044090170000MU
... 1099107TJ3419N0001RR
... 1344504PD5614S0001XE
... 1468103QC6316N0001PQ
... 1470436TJ5117S0001EP
... 15001A005004610000JK
... 15001A005004620000JR
... 15037A024005060000PX
... 1665311QC6316S0001OO
... 1811701QC3711S0001RM
... 1927510QD2812N0001GJ
... 2014801QC3721S0001IR
... 2019001QD2821N0001QR
... 2035116PD7423N0001WL
... 2070105TK4027A0001XW
... 2093020TK8129S0005RA
... 2106409QE0520N0001IO
... 2209001TK5620N0001LL
... 2217331QC3721N0001GL
... 2272003TJ5127S0001JF
... 2335208QC5823N0001YD
... 2372801QC0427S0001MO
... 2380105PC8328S0001PS
... 2409516TK5620N0001HL
... 2444001QD2724C0001EB
... 2595010TK8129N0001XX
... 2641303TK5424S0001WH
... 2667407TJ5126N0001RS
... 2735401PD7423N0001AL
... 2750203PC9625S0001BA
... 2787101TK8128N0001MT
... 2792003TK8129S0001QU
... 2792020TJ6029S0001IO
... 2911401TJ4521S0001BS
... 2951205TJ7025S0001RX
... 3012723TJ4531S0001DH
... 3065602TH8836N0001KA
... 3117006QC3731N0001KM
... 3135901PD7033E0001MF
... 3174922NH0737S0011QS
... 3174932NH0737S0001AT
... 3178101UJ2337N0001IB
... 3327002TJ6332N0001QH
... 3368022PE8136N0001LJ
... 3390803PC9439S0001XR
... 3456202TK7435N0001OU
... 3575302TJ6437N0001QF
... 3809537QC3230N0001JR
... 4028713TK8142N0001TE
... 4045111TK8444N0001KY
... 4443202PD7044C0068ZB
... 4471131PD7047A0001DR
... 4578201UJ0147N0001HD
... 4637801TK6843N0001WI
... 4878424TK6347N0001GT
... 4926002QE4142N0001UP
... 50210A003001510000LT
... 5034623PC6853S0001MO
... 5078102VK8957N0001TB
... 5172401PD7057A0001HI
... 5215006QC5751N0001EO
... 5238069TJ6253N0001PD
... 5335702QE3853N0001AI
... 5342201QC2854S0001WF
... 5347806UK9354N0001RU
... 5349709QC2854N0001FY
... 5410808QD5451S0001SJ
... 5417221QC5751N0001JO
... 5443405UK9354S0001BG
... 5468703QC3356N0001JR
... 5539105PC6853N0001KQ
... 5552401TK6255S0001YQ
... 5640007TJ6254S0001FG
... 5670823QC3357S0001AY
... 5867418QD1256N0001UD
... 5967307QC0256N0001GO
... 5972003QD1257S0001MG
... 6026813QD2762E0001WB
... 6043208PD9164C0001GI
... 6045303QE1564N0001UD
... 6050201PD7065A0001KQ
... 6061002QC2566S0001DF
... 6117611QC4261N0001UX
... 6229101QD2762G0001UG
... 6284203TH6368S0001UH
... 6320001QD2161N0001LI
... 6326404QD2762E0001MB
... 6380501UH0868S0001LT
... 6396405TJ8269N0001QT
... 6407102TJ8360N0001SK
... 6528901UJ0262N0001PP
... 6534011PC9763S0001YZ
... 6537302PD7063H0001WU
... 6595333QD0069N0001OM
... 6642023PD7064F0001SY
... 6684201VK8968S0002RR
... 6743701QD2764D0001IX
... 6795121QD0069N0008EU
... 6821105TK5662S0001QI
... 6822811QD2162S0001GP
... 6837203FT3063N0001YP
... 6893505QC5569S0001LO
... 6991224PD3869S0001FW
... 7076102TJ5177N0001ZE
... 7174002QD2077S0001XW
... 7244002PD7074C0001QY
... 7282901TJ5178S0001BT
... 7383502VK8978S0001PU
... 7384201TJ5178S0012WD
... 7384201TJ5178S0019OB
... 7384201TJ5178S0043QS
... 7479113QE2477N0001UY
... 7499524NH0179N0001RJ
... 7570012TJ4377S0001PO
... 7640222QE4374B0001FR
... 7682601TJ5178S0001XT
... 7749401PD7074H0001HT
... 7865002TJ4376N0001TU
... 7865004TJ4376N0001MU
... 7865006TJ4376N0001KU
... 7977802TJ5177N0001TE
... 8327413PE8482N0001HU
... 8344202PC6684S0001FT
... 8354003PD7085C0001RR
... 8384416TJ8688S0001IQ
... 8579507NH0387N0001QB
... 8645036TJ5984N0001TL
... 8670604TJ4587S0004BE
... 8679007TJ5187N0001LU
... 8696402TH7889N0001XQ
... 8696802TH7889N0001GQ
... 8701105PD7180B0001AU
... 8701110PD7180B0001YU
... 8788845QC2588H0001IJ
... 8796005QD2089N0001WO
... 8796022QD2089N0001OO
... 8827314QD5282N0001RT
... 8843501PC7484S0001KU
... 8910403QD3481S0001LT
... 8990307TH7889S0001OO
... 9013602QD2191S0001ET
... 9165501QE4396E0001YR
... 9201801QD2190S0001PA
... 9205301VL8090N0001PW
... 9265801QE4396E0001PR
... 9327401QE3592N0001JG
... 9655311TK9195N0001OJ
... 9712301QD2191S0001DT
... 9811901DS3191S0001QY
... 9811901TN8391S0001QM
... 9815402PD9391N0001PO
... 9854802PD7195D0001MX
... 9872023 VH5797S 0001 WX
... 9953001PD7195D0001GX
... 9988220VK8998N0001JU
... 9996812TJ9699N0001ZE
...
... '''
>>> [x for x in numbers.splitlines() if x and not referenciacatastral.is_valid(x)]
[]