├── .gitignore ├── LICENSE ├── README.md ├── data └── DIMIF-queima.csv ├── docs ├── doubles.md ├── revisao.md ├── unittest.md └── unittest_mock.md └── static └── img ├── TDD_Global_Lifecycle.png └── unit-test.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutorial de Mocks 2 | Tutorial mão na massa sobre Mocks em testes unitários Python 3 | 4 | ## Conteúdo 5 | 6 | 1. [Revisão sobre testes automatizados](/docs/revisao.md) 7 | 2. [Test Doubles (ou Mocks para os íntimos)](/docs/doubles.md) 8 | 3. [Unittest: testes automatizados usando Just Python](/docs/unittest.md) 9 | 4. [unittest.mock](/docs/unittest_mock.md) 10 | 11 | 12 | ## Referências 13 | 14 | * Hands-On Test Driven Development with Python: Test Doubles & unittest.mock Framework, packtpub.com, publicado em 07/06/2018: https://youtu.be/qE33pF3TTos 15 | * The Little Mocker, Robert C. Martin (Uncle Bob), publicado em 14/05/2014: https://blog.cleancoder.com/uncle-bob/2014/05/14/TheLittleMocker.html 16 | * Unit testing, wikipedia: https://en.wikipedia.org/wiki/Unit_testing 17 | * Mocks Aren't Stubs, publicado em 02/01/2007: https://martinfowler.com/articles/mocksArentStubs.html 18 | -------------------------------------------------------------------------------- /data/DIMIF-queima.csv: -------------------------------------------------------------------------------- 1 | Código CNUC;Nome da UC;Categoria da UC: sigla federal;Categoria da UC: nomenclatura nacional;Grupo de Proteção;Ano de criação;Coordenação Regional do ICMBio;Área estimada da UC (ha);Bioma referencial;Área queimada em 2018;Área queimada em 2017;Área queimada em 2016;Área queimada em 2015;Área queimada em 2014;Área queimada em 2013;Área queimada em 2012 2 | 0000.00.0001;APA Anhatomirim;APA;Área de Proteção Ambiental;uso sustentável;1992;CR9 Florianópolis/SC;4.437;Marinho-Costeiro;;;;;;; 3 | 0000.00.1521;APA Bacia Hidrográfica do Rio Paraíba do Sul;APA;Área de Proteção Ambiental;uso sustentável;1982;CR8 Rio de Janeiro/RJ;292.600;Mata Atlântica;;182,1;;;;; 4 | 0000.00.0007;APA Barra do Rio Mamanguape;APA;Área de Proteção Ambiental;uso sustentável;1993;CR6 Cabedelo/PB;14.918;Marinho-Costeiro;;;;;;; 5 | 0000.00.0020;APA Carste da Lagoa Santa;APA;Área de Proteção Ambiental;uso sustentável;1990;CR11 Lagoa Santa/MG;39.957;Cerrado;;;;;;; 6 | 0000.00.0002;APA Cavernas do Peruaçu;APA;Área de Proteção Ambiental;uso sustentável;1989;CR11 Lagoa Santa/MG;143.356;Cerrado;;260,7;;;;; 7 | 0000.00.0008;APA Chapada do Araripe;APA;Área de Proteção Ambiental;uso sustentável;1997;CR6 Cabedelo/PB;972.605;Caatinga;;;;;;; 8 | 0000.00.1912;APA Costa das Algas;APA;Área de Proteção Ambiental;uso sustentável;2010;CR7 Porto Seguro/BA;114.805;Mata Atlântica;;;;;;; 9 | 0000.00.0009;APA Costa dos Corais;APA;Área de Proteção Ambiental;uso sustentável;1997;CR6 Cabedelo/PB;404.286;Marinho-Costeiro;;;;;;; 10 | 0000.00.0003;APA da Bacia do Rio Descoberto;APA;Área de Proteção Ambiental;uso sustentável;1983;CR11 Lagoa Santa/MG;41.784;Cerrado;;1.585,4;;;;; 11 | 0000.00.0004;APA da Bacia do Rio São Bartolomeu;APA;Área de Proteção Ambiental;uso sustentável;1983;CR11 Lagoa Santa/MG;82.681;Cerrado;;1.620,0;;;;; 12 | 0000.00.0005;APA da Bacia do Rio São João - Mico-Leão-Dourado;APA;Área de Proteção Ambiental;uso sustentável;2002;CR8 Rio de Janeiro/RJ;150.375;Mata Atlântica;;;;;;; 13 | 0000.00.0006;APA da Baleia Franca;APA;Área de Proteção Ambiental;uso sustentável;2000;CR9 Florianópolis/SC;154.867;Marinho-Costeiro;;;;;;; 14 | 0000.00.0025;APA das Ilhas e Várzeas do Rio Paraná;APA;Área de Proteção Ambiental;uso sustentável;1997;CR9 Florianópolis/SC;1.005.188;Mata Atlântica;;5.972,3;;;;;14.447,0 15 | 0000.00.0028;APA das Nascentes do Rio Vermelho;APA;Área de Proteção Ambiental;uso sustentável;2001;CR11 Lagoa Santa/MG;176.324;Cerrado;;7.592,3;;;;; 16 | 0000.00.0013;APA de Cairuçu;APA;Área de Proteção Ambiental;uso sustentável;1983;CR8 Rio de Janeiro/RJ;32.611;Marinho-Costeiro;;;;;;; 17 | 0000.00.0014;APA de Cananéia-Iguape-Peruíbe;APA;Área de Proteção Ambiental;uso sustentável;1984;CR8 Rio de Janeiro/RJ;202.310;Marinho-Costeiro;;;;;;; 18 | 0000.00.0015;APA de Fernando de Noronha -Rocas – São Pedro e São Paulo;APA;Área de Proteção Ambiental;uso sustentável;1986;CR6 Cabedelo/PB;884;Marinho-Costeiro;;;;;;; 19 | 0000.00.0016;APA de Guapi-Mirim;APA;Área de Proteção Ambiental;uso sustentável;1984;CR8 Rio de Janeiro/RJ;13.927;Marinho-Costeiro;;;;;;; 20 | 0000.00.0017;APA de Guaraqueçaba;APA;Área de Proteção Ambiental;uso sustentável;1985;CR9 Florianópolis/SC;282.446;Mata Atlântica;;;;;;; 21 | 0000.00.0010;APA de Petrópolis;APA;Área de Proteção Ambiental;uso sustentável;1982;CR8 Rio de Janeiro/RJ;68.224;Mata Atlântica;;;;;;; 22 | 0000.00.0018;APA de Piaçabuçu;APA;Área de Proteção Ambiental;uso sustentável;1983;CR6 Cabedelo/PB;9.107;Marinho-Costeiro;;;;;;; 23 | 0000.00.0019;APA Delta do Parnaíba;APA;Área de Proteção Ambiental;uso sustentável;1996;CR5 Parnaíba/PI;307.595;Marinho-Costeiro;;1.367,1;;;;; 24 | 0000.00.0022;APA do Igarapé Gelado;APA;Área de Proteção Ambiental;uso sustentável;1989;CR4 Belém/PA;23.285;Amazônia;;;;;;; 25 | 0000.00.0023;APA do Planalto Central;APA;Área de Proteção Ambiental;uso sustentável;2002;CR11 Lagoa Santa/MG;503.423;Cerrado;;13.509,7;;;;; 26 | 0000.00.0268;APA do Tapajós;APA;Área de Proteção Ambiental;uso sustentável;2006;CR3 Santarém/PA;2.040.331;Amazônia;;;;;;;598,9 27 | 0000.00.3407;APA dos Campos de Manicoré;APA;Área de Proteção Ambiental;uso sustentável;2016;CR1 Porto Velho/RO;151.993;Amazônia;;;;;;; 28 | 0000.00.0021;APA Ibirapuitã;APA;Área de Proteção Ambiental;uso sustentável;1992;CR9 Florianópolis/SC;316.792;Pampas;;;;;;; 29 | 0000.00.0024;APA Meandros do Araguaia;APA;Área de Proteção Ambiental;uso sustentável;1998;CR10 Cuiabá/MT;359.194;Cerrado;;114.142,6;;;;;82.626,4 30 | 0000.00.0027;APA Morro da Pedreira;APA;Área de Proteção Ambiental;uso sustentável;1990;CR11 Lagoa Santa/MG;131.771;Cerrado;;360,3;5.852,6;6.669,0;;;1.107,7 31 | 0000.00.0029;APA Serra da Ibiapaba;APA;Área de Proteção Ambiental;uso sustentável;1996;CR5 Parnaíba/PI;1.628.450;Caatinga;;9.986,1;;;;; 32 | 0000.00.0011;APA Serra da Mantiqueira;APA;Área de Proteção Ambiental;uso sustentável;1985;CR8 Rio de Janeiro/RJ;421.809;Mata Atlântica;;3.703,6;;;;; 33 | 0000.00.1683;APA Serra da Meruoca;APA;Área de Proteção Ambiental;uso sustentável;2008;CR5 Parnaíba/PI;29.362;Caatinga;;;;;;; 34 | 0000.00.0012;APA Serra da Tabatinga;APA;Área de Proteção Ambiental;uso sustentável;1990;CR5 Parnaíba/PI;35.186;Cerrado;;;;;;; 35 | 0000.00.0030;ARIE Buriti de Vassununga;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1990;CR11 Lagoa Santa/MG;151;Mata Atlântica;;;;;;; 36 | 0000.00.0031;ARIE Capetinga-Taquara;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR11 Lagoa Santa/MG;2.057;Cerrado;;;;;;; 37 | 0000.00.0032;ARIE Cerrado Pé-de-Gigante;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1990;CR8 Rio de Janeiro/RJ;1.199;Mata Atlântica;;;;;;; 38 | 0000.00.0035;ARIE Floresta da Cicuta;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR8 Rio de Janeiro/RJ;125;Mata Atlântica;;;;;;; 39 | 0000.00.0036;ARIE Ilha do Ameixal;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR8 Rio de Janeiro/RJ;359;Marinho-Costeiro;;;;;;; 40 | 0000.00.0037;ARIE Ilhas da Queimada Pequena e Queimada Grande;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR8 Rio de Janeiro/RJ;138;Marinho-Costeiro;;;;;;; 41 | 0000.00.0038;ARIE Javari-Buriti;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR2 Manaus/AM;13.177;Amazônia;;;;;;; 42 | 0000.00.0039;ARIE Manguezais da Foz do Rio Mamanguape;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR6 Cabedelo/PB;5.770;Marinho-Costeiro;;;;;;; 43 | 0000.00.0040;ARIE Mata de Santa Genebra;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR8 Rio de Janeiro/RJ;242;Mata Atlântica;;;;;;; 44 | 0000.00.0041;ARIE Matão de Cosmópolis;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR8 Rio de Janeiro/RJ;229;Cerrado;;;;;;; 45 | 0000.00.0043;ARIE Projeto Dinâmica Biológica de Fragmentos Florestais;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1985;CR2 Manaus/AM;3.180;Amazônia;;;;;;; 46 | 0000.00.0044;ARIE Seringal Nova Esperança;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1999;CR1 Porto Velho/RO;2.574;Amazônia;;;;;;; 47 | 0000.00.0045;ARIE Serra da Abelha e Rio da Prata;ARIE;Área de Relevante Interesse Ecológico;uso sustentável;1990;CR9 Florianópolis/SC;5.017;Mata Atlântica;;;;;;; 48 | 0000.00.3131;ESEC Alto Maués;ESEC;Estação Ecológica;proteção integral;2014;CR2 Manaus/AM;668.160;Amazônia;;;;;;; 49 | 0000.00.0263;ESEC da Guanabara;ESEC;Estação Ecológica;proteção integral;2006;CR8 Rio de Janeiro/RJ;1.936;Mata Atlântica;;;;;;; 50 | 0000.00.0261;ESEC da Mata Preta;ESEC;Estação Ecológica;proteção integral;2005;CR9 Florianópolis/SC;6.567;Mata Atlântica;;;;;;; 51 | 0000.00.0075;ESEC da Serra das Araras;ESEC;Estação Ecológica;proteção integral;1982;CR10 Cuiabá/MT;27.160;Cerrado;;2.450,4;;;;; 52 | 0000.00.0047;ESEC da Terra do Meio;ESEC;Estação Ecológica;proteção integral;2005;CR3 Santarém/PA;3.373.175;Amazônia;365,3;8.815,1;347,8;2.599,2;766,6;;2.136,9 53 | 0000.00.0048;ESEC de Aiuaba;ESEC;Estação Ecológica;proteção integral;2001;CR6 Cabedelo/PB;11.747;Caatinga;;;;;;; 54 | 0000.00.0050;ESEC de Aracuri-Esmeralda;ESEC;Estação Ecológica;proteção integral;1981;CR9 Florianópolis/SC;277;Mata Atlântica;;;;;;; 55 | 0000.00.0051;ESEC de Caracaraí;ESEC;Estação Ecológica;proteção integral;1982;CR2 Manaus/AM;86.795;Amazônia;;;731,4;3.975,5;291,7;; 56 | 0000.00.0052;ESEC de Carijós;ESEC;Estação Ecológica;proteção integral;1987;CR9 Florianópolis/SC;759;Mata Atlântica;;;;;;; 57 | 0000.00.0053;ESEC de Cuniã;ESEC;Estação Ecológica;proteção integral;2001;CR1 Porto Velho/RO;185.314;Amazônia;1.088,6;;;;;4.451,2;672,8 58 | 0000.00.0054;ESEC de Guaraqueçaba;ESEC;Estação Ecológica;proteção integral;1982;CR9 Florianópolis/SC;4.476;Mata Atlântica;;;;;;; 59 | 0000.00.0055;ESEC de Iquê;ESEC;Estação Ecológica;proteção integral;1981;CR10 Cuiabá/MT;215.971;Cerrado;;440,4;;;;; 60 | 0000.00.0056;ESEC de Jutaí-Solimões;ESEC;Estação Ecológica;proteção integral;1983;CR2 Manaus/AM;289.514;Amazônia;;;;;;; 61 | 0000.00.0057;ESEC de Maracá;ESEC;Estação Ecológica;proteção integral;1981;CR2 Manaus/AM;103.520;Amazônia;;;;;;; 62 | 0000.00.0058;ESEC de Maracá Jipioca;ESEC;Estação Ecológica;proteção integral;1981;CR4 Belém/PA;60.253;Amazônia;;;;;;; 63 | 0000.00.0059;ESEC de Murici;ESEC;Estação Ecológica;proteção integral;2001;CR6 Cabedelo/PB;6.132;Mata Atlântica;;;;;;; 64 | 0000.00.0061;ESEC de Pirapitinga;ESEC;Estação Ecológica;proteção integral;1987;CR11 Lagoa Santa/MG;1.385;Cerrado;;;;;;; 65 | 0000.00.0062;ESEC de Taiamã;ESEC;Estação Ecológica;proteção integral;1981;CR10 Cuiabá/MT;11.555;Pantanal;;;;;;; 66 | 0000.00.0063;ESEC de Tamoios;ESEC;Estação Ecológica;proteção integral;1990;CR8 Rio de Janeiro/RJ;9.361;Mata Atlântica;;;;;;; 67 | 0000.00.0065;ESEC de Uruçui-Una;ESEC;Estação Ecológica;proteção integral;1981;CR5 Parnaíba/PI;135.122;Cerrado;19.132,7;27.425,2;28.439,7;59.146,7;34.874,5;12.267,6;65.507,6 68 | 0000.00.0066;ESEC do Castanhão;ESEC;Estação Ecológica;proteção integral;2001;CR6 Cabedelo/PB;12.575;Caatinga;1.513,1;;;;;; 69 | 0000.00.0067;ESEC do Jari;ESEC;Estação Ecológica;proteção integral;1982;CR4 Belém/PA;231.082;Amazônia;;;;;;; 70 | 0000.00.0069;ESEC do Seridó;ESEC;Estação Ecológica;proteção integral;1982;CR6 Cabedelo/PB;1.124;Caatinga;;;;;;; 71 | 0000.00.0070;ESEC do Taim;ESEC;Estação Ecológica;proteção integral;1986;CR9 Florianópolis/SC;10.939;Pampas;;;;;;3.930,4; 72 | 0000.00.0071;ESEC dos Tupiniquins;ESEC;Estação Ecológica;proteção integral;1986;CR8 Rio de Janeiro/RJ;1.728;Marinho-Costeiro;;;;;;; 73 | 0000.00.0072;ESEC Juami-Japurá;ESEC;Estação Ecológica;proteção integral;1985;CR2 Manaus/AM;831.532;Amazônia;;;;;;; 74 | 0000.00.0073;ESEC Mico-Leão-Preto;ESEC;Estação Ecológica;proteção integral;2002;CR8 Rio de Janeiro/RJ;6.681;Mata Atlântica;;;;;;; 75 | 0000.00.0060;ESEC Niquiá;ESEC;Estação Ecológica;proteção integral;1985;CR2 Manaus/AM;284.791;Amazônia;71.161,7;;;;;; 76 | 0000.00.0074;ESEC Raso da Catarina;ESEC;Estação Ecológica;proteção integral;1984;CR6 Cabedelo/PB;104.844;Caatinga;;;;1.758,2;;; 77 | 0000.00.0068;ESEC Rio Acre;ESEC;Estação Ecológica;proteção integral;1981;CR1 Porto Velho/RO;79.094;Amazônia;;;;;;; 78 | 0000.00.0076;ESEC Serra Geral do Tocantins;ESEC;Estação Ecológica;proteção integral;2001;CR5 Parnaíba/PI;707.088;Cerrado;141.042,2;185.744,1;229.960,2;233.367,8;286.303,7;192.624,9;251.539,1 79 | 0000.00.0064;ESEC Tupinambás;ESEC;Estação Ecológica;proteção integral;1987;CR8 Rio de Janeiro/RJ;2.464;Marinho-Costeiro;;;;;;; 80 | 0000.00.0128;FLONA da Mata Grande;FLONA;Floresta;uso sustentável;2003;CR11 Lagoa Santa/MG;2.010;Cerrado;;;;;;; 81 | 0000.00.0132;FLONA da Restinga de Cabedelo;FLONA;Floresta;uso sustentável;2004;CR6 Cabedelo/PB;115;Mata Atlântica;;;;;;; 82 | 0000.00.0082;FLONA de Açu;FLONA;Floresta;uso sustentável;2001;CR6 Cabedelo/PB;218;Caatinga;;;;;;; 83 | 0000.00.0083;FLONA de Altamira;FLONA;Floresta;uso sustentável;1998;CR3 Santarém/PA;724.974;Amazônia;306,8;5.562,9;3.586,4;3.223,1;3.284,5;;3.389,3 84 | 0000.00.0084;FLONA de Anauá;FLONA;Floresta;uso sustentável;2005;CR2 Manaus/AM;259.403;Amazônia;;;;;;; 85 | 0000.00.0077;FLONA de Assungui;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;561;Mata Atlântica;;;;;;; 86 | 0000.00.0085;FLONA de Balata-Tufari;FLONA;Floresta;uso sustentável;2005;CR1 Porto Velho/RO;1.079.678;Amazônia;1.103,9;;587,3;;;; 87 | 0000.00.0086;FLONA de Brasília;FLONA;Floresta;uso sustentável;1999;CR11 Lagoa Santa/MG;9.336;Cerrado;;2.634,6;1.610,4;760,5;984,6;406,8; 88 | 0000.00.0078;FLONA de Caçador;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;707;Mata Atlântica;;;;;;; 89 | 0000.00.0087;FLONA de Canela;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;564;Mata Atlântica;;;;;;; 90 | 0000.00.0079;FLONA de Capão Bonito;FLONA;Floresta;uso sustentável;1968;CR8 Rio de Janeiro/RJ;4.758;Cerrado;;;;;;; 91 | 0000.00.0088;FLONA de Carajás;FLONA;Floresta;uso sustentável;1998;CR4 Belém/PA;392.730;Amazônia;;290,5;;;;; 92 | 0000.00.0089;FLONA de Caxiuana;FLONA;Floresta;uso sustentável;1961;CR4 Belém/PA;317.951;Amazônia;;;;;;; 93 | 0000.00.0080;FLONA de Chapecó;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;1.604;Mata Atlântica;;;;;;; 94 | 0000.00.0081;FLONA de Contendas do Sincorá;FLONA;Floresta;uso sustentável;1999;CR7 Porto Seguro/BA;11.216;Caatinga;;;;;;; 95 | 0000.00.0090;FLONA de Cristópolis;FLONA;Floresta;uso sustentável;2001;CR7 Porto Seguro/BA;12.841;Cerrado;328,8;;;;;; 96 | 0000.00.0091;FLONA de Goytacazes;FLONA;Floresta;uso sustentável;2002;CR7 Porto Seguro/BA;1.426;Mata Atlântica;;;;;;; 97 | 0000.00.0092;FLONA de Humaitá;FLONA;Floresta;uso sustentável;1998;CR1 Porto Velho/RO;473.159;Amazônia;;;;;;; 98 | 0000.00.0093;FLONA de Ibirama;FLONA;Floresta;uso sustentável;1988;CR9 Florianópolis/SC;519;Mata Atlântica;;;;;;; 99 | 0000.00.0094;FLONA de Ipanema;FLONA;Floresta;uso sustentável;1992;CR8 Rio de Janeiro/RJ;5.385;Mata Atlântica;11,4;;;;;; 100 | 0000.00.0125;FLONA de Irati;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;3.803;Mata Atlântica;;;;;;; 101 | 0000.00.0095;FLONA de Itaituba I;FLONA;Floresta;uso sustentável;1998;CR3 Santarém/PA;212.892;Amazônia;;;;;;; 102 | 0000.00.0096;FLONA de Itaituba II;FLONA;Floresta;uso sustentável;1998;CR3 Santarém/PA;397.756;Amazônia;;1.293,6;;;;; 103 | 0000.00.0097;FLONA de Jacundá;FLONA;Floresta;uso sustentável;2004;CR1 Porto Velho/RO;221.220;Amazônia;;182,6;;;;; 104 | 0000.00.0098;FLONA de Lorena;FLONA;Floresta;uso sustentável;2001;CR8 Rio de Janeiro/RJ;281;Mata Atlântica;;;;;;; 105 | 0000.00.0099;FLONA de Mulata;FLONA;Floresta;uso sustentável;2001;CR3 Santarém/PA;216.604;Amazônia;;;;584,1;;; 106 | 0000.00.1605;FLONA de Negreiros;FLONA;Floresta;uso sustentável;2007;CR6 Cabedelo/PB;3.005;Caatinga;;;;;;; 107 | 0000.00.0100;FLONA de Nísia Floresta;FLONA;Floresta;uso sustentável;2001;CR6 Cabedelo/PB;169;Mata Atlântica;;;;;;; 108 | 0000.00.0101;FLONA de Pacotuba;FLONA;Floresta;uso sustentável;2002;CR7 Porto Seguro/BA;449;Mata Atlântica;;;;;;; 109 | 0000.00.0102;FLONA de Palmares;FLONA;Floresta;uso sustentável;2005;CR5 Parnaíba/PI;168;Caatinga;;;;;;; 110 | 0000.00.0103;FLONA de Paraopeba;FLONA;Floresta;uso sustentável;2001;CR11 Lagoa Santa/MG;203;Cerrado;;;;;;; 111 | 0000.00.0129;FLONA de Passa Quatro;FLONA;Floresta;uso sustentável;1968;CR8 Rio de Janeiro/RJ;335;Mata Atlântica;;;;;;; 112 | 0000.00.0130;FLONA de Passo Fundo;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;1.334;Mata Atlântica;;;;;;; 113 | 0000.00.0104;FLONA de Pau-Rosa;FLONA;Floresta;uso sustentável;2001;CR2 Manaus/AM;988.187;Amazônia;;;;;;; 114 | 0000.00.0131;FLONA de Piraí do Sul;FLONA;Floresta;uso sustentável;2004;CR9 Florianópolis/SC;170;Mata Atlântica;;;;;;; 115 | 0000.00.0105;FLONA de Ritápolis;FLONA;Floresta;uso sustentável;1999;CR11 Lagoa Santa/MG;89;Mata Atlântica;;;;;;; 116 | 0000.00.0106;FLONA de Roraima;FLONA;Floresta;uso sustentável;1989;CR2 Manaus/AM;167.332;Amazônia;1.382,4;;1.584,6;696,9;;; 117 | 0000.00.0107;FLONA de Santa Rosa do Purus;FLONA;Floresta;uso sustentável;2001;CR1 Porto Velho/RO;231.557;Amazônia;;;;;;; 118 | 0000.00.0108;FLONA de São Francisco;FLONA;Floresta;uso sustentável;2001;CR1 Porto Velho/RO;21.148;Amazônia;;;;;;; 119 | 0000.00.0133;FLONA de São Francisco de Paula;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;1.616;Mata Atlântica;;;;;;; 120 | 0000.00.0110;FLONA de Silvânia;FLONA;Floresta;uso sustentável;2001;CR11 Lagoa Santa/MG;487;Cerrado;;;;;;; 121 | 0000.00.0111;FLONA de Sobral;FLONA;Floresta;uso sustentável;2001;CR5 Parnaíba/PI;661;Caatinga;;;;;;; 122 | 0000.00.0112;FLONA de Tefé;FLONA;Floresta;uso sustentável;1989;CR2 Manaus/AM;865.127;Amazônia;;;;;;; 123 | 0000.00.0134;FLONA de Três Barras;FLONA;Floresta;uso sustentável;1968;CR9 Florianópolis/SC;4.385;Mata Atlântica;;;;;;; 124 | 0000.00.3408;FLONA de Urupadi;FLONA;Floresta;uso sustentável;2016;CR1 Porto Velho/RO;537.228;Amazônia;;;;;;; 125 | 0000.00.0271;FLONA do Amana;FLONA;Floresta;uso sustentável;2006;CR3 Santarém/PA;680.843;Amazônia;;;;;;; 126 | 0000.00.0113;FLONA do Amapá;FLONA;Floresta;uso sustentável;1989;CR4 Belém/PA;460.359;Amazônia;;;;;;; 127 | 0000.00.0114;FLONA do Amazonas;FLONA;Floresta;uso sustentável;1989;CR2 Manaus/AM;1.944.230;Amazônia;;;2.830,4;;;; 128 | 0000.00.0115;FLONA do Araripe-Apodi;FLONA;Floresta;uso sustentável;1946;CR6 Cabedelo/PB;38.920;Caatinga;;;;;;; 129 | 0000.00.3409;FLONA do Aripuanã;FLONA;Floresta;uso sustentável;2016;CR1 Porto Velho/RO;751.295;Amazônia;331,8;531,8;;;;; 130 | 0000.00.0116;FLONA do Bom Futuro;FLONA;Floresta;uso sustentável;1988;CR1 Porto Velho/RO;97.385;Amazônia;2.909,8;5.056,2;1.299,2;3.956,6;805,8;85,2;3.543,3 131 | 0000.00.0270;FLONA do Crepori;FLONA;Floresta;uso sustentável;2006;CR3 Santarém/PA;740.396;Amazônia;;;;;;; 132 | 0000.00.0269;FLONA do Ibura;FLONA;Floresta;uso sustentável;2005;CR6 Cabedelo/PB;144;Mata Atlântica;;;;;;; 133 | 0000.00.1612;FLONA do Iquiri;FLONA;Floresta;uso sustentável;2008;CR1 Porto Velho/RO;1.472.610;Amazônia;;;;410,3;;;1.104,2 134 | 0000.00.0117;FLONA do Itacaiunas;FLONA;Floresta;uso sustentável;1998;CR4 Belém/PA;136.701;Amazônia;;1.107,8;237,7;;;153,9; 135 | 0000.00.0266;FLONA do Jamanxim;FLONA;Floresta;uso sustentável;2006;CR3 Santarém/PA;1.301.697;Amazônia;17.203,9;37.380,6;25.239,7;30.275,2;16.660,3;2.879,6;14.298,7 136 | 0000.00.0118;FLONA do Jamari;FLONA;Floresta;uso sustentável;1984;CR1 Porto Velho/RO;222.116;Amazônia;;40,2;;;;; 137 | 0000.00.0119;FLONA do Jatuarana;FLONA;Floresta;uso sustentável;2002;CR1 Porto Velho/RO;569.428;Amazônia;;;;;;; 138 | 0000.00.0120;FLONA do Macauã;FLONA;Floresta;uso sustentável;1988;CR1 Porto Velho/RO;176.347;Amazônia;;;;;;; 139 | 0000.00.0121;FLONA do Purus;FLONA;Floresta;uso sustentável;1988;CR1 Porto Velho/RO;256.123;Amazônia;;;;;;; 140 | 0000.00.0122;FLONA do Rio Preto;FLONA;Floresta;uso sustentável;1990;CR7 Porto Seguro/BA;2.817;Mata Atlântica;;;;;;; 141 | 0000.00.0123;FLONA do Tapajós;FLONA;Floresta;uso sustentável;1974;CR3 Santarém/PA;530.621;Amazônia;;;;;;; 142 | 0000.00.0124;FLONA do TapirapéAquiri;FLONA;Floresta;uso sustentável;1989;CR4 Belém/PA;196.506;Amazônia;;;;;;; 143 | 0000.00.0265;FLONA do Trairão;FLONA;Floresta;uso sustentável;2006;CR3 Santarém/PA;257.529;Amazônia;;;;;;; 144 | 0000.00.0126;FLONA Mapiá-Inauini;FLONA;Floresta;uso sustentável;1989;CR1 Porto Velho/RO;368.950;Amazônia;;;;;;; 145 | 0000.00.0127;FLONA Mário Xavier;FLONA;Floresta;uso sustentável;1986;CR8 Rio de Janeiro/RJ;496;Mata Atlântica;;;;;;; 146 | 0000.00.0109;FLONA Sarará-Taquara;FLONA;Floresta;uso sustentável;1989;CR3 Santarém/PA;441.288;Amazônia;;;;;;; 147 | 0000.00.0034;MONA das Ilhas Cagarras;MONA;Monumento Natural;proteção integral;2010;CR8 Rio de Janeiro/RJ;106;Marinho-Costeiro;;;;;;; 148 | 0000.00.1812;MONA do Rio São Francisco;MONA;Monumento Natural;proteção integral;2009;CR6 Cabedelo/PB;26.737;Caatinga;;;;;;; 149 | 0000.00.0181;MONA dos Pontões Capixabas;MONA;Monumento Natural;proteção integral;2008;CR7 Porto Seguro/BA;17.444;Mata Atlântica;;85,5;;;;; 150 | 0000.00.0135;PARNA Cavernas do Peruaçu;PARNA;Parque;proteção integral;1999;CR11 Lagoa Santa/MG;56.449;Cerrado;;;;;;; 151 | 0000.00.0136;PARNA da Amazônia;PARNA;Parque;proteção integral;1974;CR3 Santarém/PA;1.066.208;Amazônia;;;;;;; 152 | 0000.00.0272;PARNA da Chapada das Mesas;PARNA;Parque;proteção integral;2005;CR5 Parnaíba/PI;159.954;Cerrado;;20.046,7;;19.498,7;20.980,8;34.850,9;16.956,9 153 | 0000.00.0137;PARNA da Chapada Diamantina;PARNA;Parque;proteção integral;1985;CR7 Porto Seguro/BA;152.144;Caatinga;3.958,8;356,0;2.274,8;32.997,9;;2.733,6;6.963,6 154 | 0000.00.0138;PARNA da Chapada dos Guimarães;PARNA;Parque;proteção integral;1989;CR10 Cuiabá/MT;32.647;Cerrado;;4.309,5;2.651,7;6.643,0;;;1.903,4 155 | 0000.00.0139;PARNA da Chapada dos Veadeiros;PARNA;Parque;proteção integral;1961;CR11 Lagoa Santa/MG;64.796;Cerrado;13.384,4;86.492,0;183,8;14.581,2;8.554,8;453,1;6.279,7 156 | 0000.00.2633;PARNA da Furna Feia;PARNA;Parque;proteção integral;2012;CR6 Cabedelo/PB;8.518;Caatinga;;;;;;; 157 | 0000.00.0140;PARNA da Lagoa do Peixe;PARNA;Parque;proteção integral;1986;CR9 Florianópolis/SC;36.722;Pampas;;69,6;;;;; 158 | 0000.00.0141;PARNA da Restinga de Jurubatiba;PARNA;Parque;proteção integral;1998;CR8 Rio de Janeiro/RJ;14.867;Mata Atlântica;;;;;;; 159 | 0000.00.0142;PARNA da Serra da Bocaina;PARNA;Parque;proteção integral;1971;CR8 Rio de Janeiro/RJ;104.046;Mata Atlântica;;1.012,0;;;;; 160 | 0000.00.0143;PARNA da Serra da Bodoquena;PARNA;Parque;proteção integral;2000;CR10 Cuiabá/MT;77.022;Cerrado;;;;;;; 161 | 0000.00.0144;PARNA da Serra da Canastra;PARNA;Parque;proteção integral;1972;CR11 Lagoa Santa/MG;197.812;Cerrado;44.544,0;50.598,5;91.519,9;36.937,4;92.584,6;12.548,2;88.365,5 162 | 0000.00.0145;PARNA da Serra da Capivara;PARNA;Parque;proteção integral;1979;CR5 Parnaíba/PI;100.764;Caatinga;;;;;;; 163 | 0000.00.0188;PARNA da Serra da Cutia;PARNA;Parque;proteção integral;2001;CR1 Porto Velho/RO;283.503;Amazônia;;;2.474,1;;;; 164 | 0000.00.0146;PARNA da Serra das Confusões;PARNA;Parque;proteção integral;1998;CR5 Parnaíba/PI;823.855;Caatinga;22.306,6;6.560,4;3.965,5;73.486,6;;11.092,1; 165 | 0000.00.1909;PARNA da Serra das Lontras;PARNA;Parque;proteção integral;2010;CR7 Porto Seguro/BA;11.344;Mata Atlântica;;;;;;; 166 | 0000.00.0148;PARNA da Serra do Cipó;PARNA;Parque;proteção integral;1984;CR11 Lagoa Santa/MG;31.640;Cerrado;;614,0;1.288,2;7.547,8;7.505,7;;6.649,1 167 | 0000.00.0149;PARNA da Serra do Divisor;PARNA;Parque;proteção integral;1989;CR1 Porto Velho/RO;837.560;Amazônia;;;;;;; 168 | 0000.00.3136;PARNA da Serra do Gandarela;PARNA;Parque;proteção integral;2014;CR11 Lagoa Santa/MG;31.284;Mata Atlântica;516,4;44,3;;470,7;;; 169 | 0000.00.0150;PARNA da Serra do Itajaí;PARNA;Parque;proteção integral;2004;CR9 Florianópolis/SC;57.375;Mata Atlântica;;;;;;; 170 | 0000.00.0151;PARNA da Serra do Pardo;PARNA;Parque;proteção integral;2005;CR3 Santarém/PA;445.413;Amazônia;;2.304,9;;;;; 171 | 0000.00.0152;PARNA da Serra dos Órgãos;PARNA;Parque;proteção integral;1939;CR8 Rio de Janeiro/RJ;20.021;Mata Atlântica;64,6;;;;;; 172 | 0000.00.0153;PARNA da Serra Geral;PARNA;Parque;proteção integral;1992;CR9 Florianópolis/SC;17.302;Mata Atlântica;;21,5;198,2;;;; 173 | 0000.00.0154;PARNA da Tijuca;PARNA;Parque;proteção integral;1961;CR8 Rio de Janeiro/RJ;3.959;Mata Atlântica;;4,9;;;;; 174 | 0000.00.0262;PARNA das Araucárias;PARNA;Parque;proteção integral;2005;CR9 Florianópolis/SC;12.810;Mata Atlântica;;;;;;; 175 | 0000.00.0155;PARNA das Emas;PARNA;Parque;proteção integral;1961;CR10 Cuiabá/MT;132.643;Cerrado;4.491,2;16.316,4;26.217,1;37.394,5;2.298,8;854,5;10.136,9 176 | 0000.00.0156;PARNA das Nascentes do Rio Parnaíba;PARNA;Parque;proteção integral;2002;CR5 Parnaíba/PI;724.334;Cerrado;84.336,8;144.402,1;171.540,8;226.328,2;149.041,6;163.208,5;153.878,6 177 | 0000.00.0157;PARNA das Sempre-Vivas;PARNA;Parque;proteção integral;2002;CR11 Lagoa Santa/MG;124.156;Cerrado;311,4;;4.052,0;3.991,2;2.216,2;; 178 | 0000.00.0049;PARNA de Anavilhanas;PARNA;Parque;proteção integral;1981;CR2 Manaus/AM;340.835;Amazônia;;;;;;; 179 | 0000.00.0158;PARNA de Aparados da Serra;PARNA;Parque;proteção integral;1959;CR9 Florianópolis/SC;13.148;Mata Atlântica;;855,6;289,0;;;; 180 | 0000.00.1908;PARNA de Boa Nova;PARNA;Parque;proteção integral;2010;CR7 Porto Seguro/BA;12.065;Mata Atlântica;;41,1;;;;; 181 | 0000.00.0159;PARNA de Brasília;PARNA;Parque;proteção integral;1961;CR11 Lagoa Santa/MG;42.356;Cerrado;;6.288,8;3.005,2;241,3;2.393,9;; 182 | 0000.00.0160;PARNA de Caparaó;PARNA;Parque;proteção integral;1961;CR11 Lagoa Santa/MG;31.763;Mata Atlântica;;180,8;;;;;710,4 183 | 0000.00.0161;PARNA de Ilha Grande;PARNA;Parque;proteção integral;1997;CR9 Florianópolis/SC;76.079;Mata Atlântica;;35.451,0;;9.662,5;10.720,5;;17.689,7 184 | 0000.00.0184;PARNA de Itatiaia;PARNA;Parque;proteção integral;1937;CR8 Rio de Janeiro/RJ;28.086;Mata Atlântica;;113,4;;;;; 185 | 0000.00.0162;PARNA de Jericoacoara;PARNA;Parque;proteção integral;2002;CR5 Parnaíba/PI;8.863;Caatinga;;;;;;; 186 | 0000.00.0163;PARNA de Pacaás Novos;PARNA;Parque;proteção integral;1979;CR1 Porto Velho/RO;708.670;Amazônia;4.706,3;2.694,2;12.787,9;9.300,7;;4.366,8;6.127,7 187 | 0000.00.0164;PARNA de Saint-Hilaire/Lange;PARNA;Parque;proteção integral;2001;CR9 Florianópolis/SC;25.119;Mata Atlântica;;;;;;; 188 | 0000.00.0165;PARNA de São Joaquim;PARNA;Parque;proteção integral;1961;CR9 Florianópolis/SC;45.524;Mata Atlântica;;;3.410,2;;;157,7; 189 | 0000.00.0166;PARNA de Sete Cidades;PARNA;Parque;proteção integral;1961;CR5 Parnaíba/PI;6.304;Caatinga;;;;;;; 190 | 0000.00.0167;PARNA de Ubajara;PARNA;Parque;proteção integral;1959;CR5 Parnaíba/PI;6.271;Caatinga;;;;;;; 191 | 0000.00.0171;PARNA Descobrimento;PARNA;Parque;proteção integral;1999;CR7 Porto Seguro/BA;22.694;Mata Atlântica;;;;192,0;309,2;; 192 | 0000.00.3410;PARNA do Acari;PARNA;Parque;proteção integral;2016;CR1 Porto Velho/RO;896.407;Amazônia;;;;;;; 193 | 0000.00.1910;PARNA do Alto Cariri;PARNA;Parque;proteção integral;2010;CR7 Porto Seguro/BA;19.238;Mata Atlântica;;;;;;; 194 | 0000.00.0168;PARNA do Araguaia;PARNA;Parque;proteção integral;1959;CR10 Cuiabá/MT;555.524;Cerrado;138.454,9;370.465,3;305.338,0;239.066,6;216.326,7;140.009,0;277.808,4 195 | 0000.00.3652;PARNA do Boqueirão da Onça;PARNA;Parque;Proteção Integral;2018;CR7 Porto Seguro/BA;346.908;Caatinga;3.224,4;;;;;; 196 | 0000.00.0169;PARNA do Cabo Orange;PARNA;Parque;proteção integral;1980;CR4 Belém/PA;657.328;Amazônia;;;4.466,5;2.254,7;;;37.480,9 197 | 0000.00.0170;PARNA do Catimbau;PARNA;Parque;proteção integral;2002;CR6 Cabedelo/PB;62.295;Caatinga;;;;;;; 198 | 0000.00.0172;PARNA do Iguaçu;PARNA;Parque;proteção integral;1939;CR9 Florianópolis/SC;169.697;Mata Atlântica;;;;;;; 199 | 0000.00.0267;PARNA do Jamanxim;PARNA;Parque;proteção integral;2006;CR3 Santarém/PA;859.807;Amazônia;;1.452,7;;1.378,1;;;380,1 200 | 0000.00.0173;PARNA do Jaú;PARNA;Parque;proteção integral;1980;CR2 Manaus/AM;2.367.357;Amazônia;;;;;;; 201 | 0000.00.0281;PARNA do Juruena;PARNA;Parque;proteção integral;2006;CR1 Porto Velho/RO;1.958.014;Amazônia;64,3;;1.063,0;;;; 202 | 0000.00.0182;PARNA do Monte Pascoal;PARNA;Parque;proteção integral;1961;CR7 Porto Seguro/BA;22.332;Mata Atlântica;;124,0;704,0;1.128,0;386,2;; 203 | 0000.00.0174;PARNA do Monte Roraima;PARNA;Parque;proteção integral;1989;CR2 Manaus/AM;116.749;Amazônia;;211,6;1.360,4;;;; 204 | 0000.00.0175;PARNA do Pantanal Mato-Grossense;PARNA;Parque;proteção integral;1981;CR10 Cuiabá/MT;135.923;Pantanal;;296,0;;;;9.534,2;673,0 205 | 0000.00.0176;PARNA do Pau Brasil;PARNA;Parque;proteção integral;1999;CR7 Porto Seguro/BA;18.935;Mata Atlântica;;;;;;; 206 | 0000.00.0177;PARNA do Pico da Neblina;PARNA;Parque;proteção integral;1979;CR2 Manaus/AM;2.252.639;Amazônia;;;;;;; 207 | 0000.00.0264;PARNA do Rio Novo;PARNA;Parque;proteção integral;2006;CR3 Santarém/PA;538.157;Amazônia;408,7;919,1;530,0;490,3;628,8;; 208 | 0000.00.0178;PARNA do Superagui;PARNA;Parque;proteção integral;1989;CR9 Florianópolis/SC;33.861;Mata Atlântica;;;;;;; 209 | 0000.00.0179;PARNA do Viruá;PARNA;Parque;proteção integral;1998;CR2 Manaus/AM;214.951;Amazônia;;;80.179,0;;;; 210 | 0000.00.0284;PARNA dos Campos Amazônicos;PARNA;Parque;proteção integral;2006;CR1 Porto Velho/RO;961.327;Amazônia;26.933,8;14.611,9;20.221,7;4.955,0;71.153,9;442,7;9.336,5 211 | 0000.00.3519;PARNA dos Campos Ferruginosos;PARNA;Parque;proteção integral;2017;CR4 Belém/PA;79.086;Amazônia;;7.173,1;;;;; 212 | 0000.00.0277;PARNA dos Campos Gerais;PARNA;Parque;proteção integral;2006;CR9 Florianópolis/SC;21.299;Mata Atlântica;;77,5;;;;; 213 | 0000.00.0180;PARNA dos Lençóis Maranhenses;PARNA;Parque;proteção integral;1981;CR5 Parnaíba/PI;156.608;Cerrado;;;;;;; 214 | 0000.00.0183;PARNA Grande Sertão Veredas;PARNA;Parque;proteção integral;1989;CR11 Lagoa Santa/MG;230.856;Cerrado;;6.232,4;1.488,8;8.653,8;605,9;2.430,8;17.043,5 215 | 0000.00.3137;PARNA Guaricana;PARNA;Parque;proteção integral;2014;CR9 Florianópolis/SC;49.300;Mata Atlântica;;;;;;; 216 | 0000.00.1633;PARNA Mapinguari;PARNA;Parque;proteção integral;2008;CR1 Porto Velho/RO;1.776.929;Amazônia;2.241,4;8.530,0;21.447,8;14.039,0;;1.241,6;22.460,5 217 | 0000.00.2874;PARNA Marinho das Ilhas dos Currais;PARNA;Parque;proteção integral;2013;CR9 Florianópolis/SC;1.360;Marinho-Costeiro;;;;;;; 218 | 0000.00.0186;PARNA Marinho de Fernando de Noronha;PARNA;Parque;proteção integral;1988;CR6 Cabedelo/PB;10.928;Marinho-Costeiro;;;;;;; 219 | 0000.00.0185;PARNA Marinho dos Abrolhos;PARNA;Parque;proteção integral;1983;CR7 Porto Seguro/BA;87.943;Marinho-Costeiro;;;;;;; 220 | 0000.00.0187;PARNA Montanhas do Tumucumaque;PARNA;Parque;proteção integral;2002;CR4 Belém/PA;3.865.172;Amazônia;;;;;;; 221 | 0000.00.1626;PARNA Nascentes do Lago Jari;PARNA;Parque;proteção integral;2008;CR2 Manaus/AM;812.753;Amazônia;;;;;;; 222 | 0000.00.0189;PARNA Serra da Mocidade;PARNA;Parque;proteção integral;1998;CR2 Manaus/AM;359.944;Amazônia;;;13.025,0;;;; 223 | 0000.00.0147;PARNA Serra de Itabaiana;PARNA;Parque;proteção integral;2005;CR6 Cabedelo/PB;7.999;Mata Atlântica;;;;;;549,8; 224 | 0000.00.0218;RDS de Itatupã-Baquiá;RDS;Reserva de Desenvolvimento Sustentável;uso sustentável;2005;CR4 Belém/PA;64.442;Amazônia;;;;;;; 225 | 0000.00.3135;RDS Nascentes Geraizeiras;RDS;Reserva de Desenvolvimento Sustentável;uso sustentável;2014;CR11 Lagoa Santa/MG;38.177;Cerrado;;;;259,0;;; 226 | 0000.00.0191;REBIO Augusto Ruschi;REBIO;Reserva Biológica;proteção integral;1982;CR7 Porto Seguro/BA;3.562;Mata Atlântica;;;;;;; 227 | 0000.00.2634;REBIO Bom Jesus;REBIO;Reserva Biológica;proteção integral;2012;CR9 Florianópolis/SC;34.179;Mata Atlântica;;;;;;; 228 | 0000.00.0192;REBIO da Contagem;REBIO;Reserva Biológica;proteção integral;2002;CR11 Lagoa Santa/MG;3.426;Cerrado;;200,9;603,5;;901,4;263,5; 229 | 0000.00.0193;REBIO da Mata Escura;REBIO;Reserva Biológica;proteção integral;2003;CR11 Lagoa Santa/MG;50.873;Mata Atlântica;443,7;;;434,9;1.487,6;; 230 | 0000.00.0276;REBIO das Araucárias;REBIO;Reserva Biológica;proteção integral;2006;CR9 Florianópolis/SC;14.930;Mata Atlântica;;;;;;; 231 | 0000.00.0275;REBIO das Perobas;REBIO;Reserva Biológica;proteção integral;2006;CR9 Florianópolis/SC;8.716;Mata Atlântica;;;;;;; 232 | 0000.00.0195;REBIO de Comboios;REBIO;Reserva Biológica;proteção integral;1984;CR7 Porto Seguro/BA;785;Marinho-Costeiro;;;;;;; 233 | 0000.00.0197;REBIO de Pedra Talhada;REBIO;Reserva Biológica;proteção integral;1989;CR6 Cabedelo/PB;4.382;Mata Atlântica;;;;;;; 234 | 0000.00.0215;REBIO de Poço das Antas;REBIO;Reserva Biológica;proteção integral;1974;CR8 Rio de Janeiro/RJ;5.053;Mata Atlântica;;;;502,9;834,2;; 235 | 0000.00.0198;REBIO de Saltinho;REBIO;Reserva Biológica;proteção integral;1983;CR6 Cabedelo/PB;563;Mata Atlântica;;;;;;; 236 | 0000.00.0199;REBIO de Santa Isabel;REBIO;Reserva Biológica;proteção integral;1988;CR6 Cabedelo/PB;5.547;Marinho-Costeiro;;;;;;; 237 | 0000.00.0200;REBIO de Serra Negra;REBIO;Reserva Biológica;proteção integral;1982;CR6 Cabedelo/PB;625;Caatinga;;;;;;; 238 | 0000.00.0201;REBIO de Sooretama;REBIO;Reserva Biológica;proteção integral;1982;CR7 Porto Seguro/BA;27.859;Mata Atlântica;;;884,1;;;; 239 | 0000.00.0202;REBIO de Una;REBIO;Reserva Biológica;proteção integral;1980;CR7 Porto Seguro/BA;18.515;Mata Atlântica;;;;;;; 240 | 0000.00.0194;REBIO do Abufari;REBIO;Reserva Biológica;proteção integral;1982;CR2 Manaus/AM;223.867;Amazônia;;;;;;; 241 | 0000.00.0203;REBIO do Atol das Rocas;REBIO;Reserva Biológica;proteção integral;1979;CR6 Cabedelo/PB;35.187;Marinho-Costeiro;;;;;;; 242 | 0000.00.0204;REBIO do Córrego do Veado;REBIO;Reserva Biológica;proteção integral;1982;CR7 Porto Seguro/BA;2.376;Mata Atlântica;;;;;;; 243 | 0000.00.0205;REBIO do Córrego Grande;REBIO;Reserva Biológica;proteção integral;1989;CR7 Porto Seguro/BA;1.504;Mata Atlântica;;;;;;; 244 | 0000.00.0206;REBIO do Guaporé;REBIO;Reserva Biológica;proteção integral;1982;CR1 Porto Velho/RO;615.776;Amazônia;18.217,7;13.826,5;30.500,6;8.121,6;983,9;6.627,4;12.034,8 245 | 0000.00.0207;REBIO do Gurupi;REBIO;Reserva Biológica;proteção integral;1988;CR4 Belém/PA;290.254;Amazônia;;266,1;;21.184,7;416,2;178,7; 246 | 0000.00.0208;REBIO do Jaru;REBIO;Reserva Biológica;proteção integral;1979;CR1 Porto Velho/RO;346.864;Amazônia;;270,0;195,6;;521,5;;112,6 247 | 0000.00.0209;REBIO do Lago Piratuba;REBIO;Reserva Biológica;proteção integral;1980;CR4 Belém/PA;392.475;Amazônia;231,4;242,6;;3.643,7;5.028,3;;14.056,8 248 | 0000.00.3411;REBIO do Manicoré;REBIO;Reserva Biológica;proteção integral;2016;CR1 Porto Velho/RO;359.063;Amazônia;716,7;;;;;; 249 | 0000.00.0210;REBIO do Rio Trombetas;REBIO;Reserva Biológica;proteção integral;1979;CR3 Santarém/PA;407.759;Amazônia;;;;;;; 250 | 0000.00.0211;REBIO do Tapirapé;REBIO;Reserva Biológica;proteção integral;1989;CR4 Belém/PA;99.273;Amazônia;;;;;;; 251 | 0000.00.0212;REBIO do Tinguá;REBIO;Reserva Biológica;proteção integral;1989;CR8 Rio de Janeiro/RJ;24.841;Mata Atlântica;;;;;;; 252 | 0000.00.0213;REBIO do Uatumã;REBIO;Reserva Biológica;proteção integral;1990;CR2 Manaus/AM;938.732;Amazônia;;;;;;; 253 | 0000.00.0196;REBIO Guaribas;REBIO;Reserva Biológica;proteção integral;1990;CR6 Cabedelo/PB;4.052;Mata Atlântica;;;;;;; 254 | 0000.00.0214;REBIO Marinha do Arvoredo;REBIO;Reserva Biológica;proteção integral;1990;CR9 Florianópolis/SC;17.105;Marinho-Costeiro;;;;;;; 255 | 0000.00.0216;REBIO Nascentes da Serra do Cachimbo;REBIO;Reserva Biológica;proteção integral;2005;CR3 Santarém/PA;342.196;Amazônia;2.325,5;22.049,3;2.271,0;2.021,4;889,0;;3.892,4 256 | 0000.00.0217;REBIO União;REBIO;Reserva Biológica;proteção integral;1998;CR8 Rio de Janeiro/RJ;2.923;Mata Atlântica;;;;;;; 257 | 0000.00.1563;RESEX Acaú-Goiana;RESEX;Reserva Extrativista;uso sustentável;2007;CR6 Cabedelo/PB;6.677;Mata Atlântica;;;;;;; 258 | 0000.00.0274;RESEX Alto Tarauacá;RESEX;Reserva Extrativista;uso sustentável;2000;CR1 Porto Velho/RO;150.924;Amazônia;;;;;;; 259 | 0000.00.0285;RESEX Arapixi;RESEX;Reserva Extrativista;uso sustentável;2006;CR1 Porto Velho/RO;133.712;Amazônia;113,5;;;;;; 260 | 0000.00.0273;RESEX Arióca Pruanã;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;83.817;Amazônia;;;;;;; 261 | 0000.00.0220;RESEX Auatí-Paraná;RESEX;Reserva Extrativista;uso sustentável;2001;CR2 Manaus/AM;146.949;Amazônia;;;;;;; 262 | 0000.00.0221;RESEX Barreiro das Antas;RESEX;Reserva Extrativista;uso sustentável;2001;CR1 Porto Velho/RO;106.199;Amazônia;;;;;;; 263 | 0000.00.1564;RESEX Chapada Limpa;RESEX;Reserva Extrativista;uso sustentável;2007;CR5 Parnaíba/PI;11.973;Cerrado;;91,4;;1.911,3;;;2.100,0 264 | 0000.00.0222;RESEX Chico Mendes;RESEX;Reserva Extrativista;uso sustentável;1990;CR1 Porto Velho/RO;931.543;Amazônia;;288,1;1.737,0;;;; 265 | 0000.00.0223;RESEX Chocoaré-Mato Grosso;RESEX;Reserva Extrativista;uso sustentável;2002;CR4 Belém/PA;2.783;Amazônia;;;;;;; 266 | 0000.00.0226;RESEX da Mata Grande;RESEX;Reserva Extrativista;uso sustentável;1992;CR4 Belém/PA;11.432;Cerrado;;;;;;; 267 | 0000.00.0253;RESEX de Canavieiras;RESEX;Reserva Extrativista;uso sustentável;2006;CR7 Porto Seguro/BA;100.728;Mata Atlântica;;126,9;;848,7;;; 268 | 0000.00.1808;RESEX de Cassurubá;RESEX;Reserva Extrativista;uso sustentável;2009;CR7 Porto Seguro/BA;100.578;Mata Atlântica;;;;;;; 269 | 0000.00.0279;RESEX de Cururupu;RESEX;Reserva Extrativista;uso sustentável;2004;CR4 Belém/PA;186.057;Amazônia;;;;;;; 270 | 0000.00.0286;RESEX de Recanto das Araras de Terra Ronca;RESEX;Reserva Extrativista;uso sustentável;2006;CR11 Lagoa Santa/MG;12.349;Cerrado;5.763,3;;1.639,3;6.630,8;;1.628,5;1.680,1 271 | 0000.00.0228;RESEX de São João da Ponta;RESEX;Reserva Extrativista;uso sustentável;2002;CR4 Belém/PA;3.409;Amazônia;;;;;;; 272 | 0000.00.1517;RESEX do Alto Juruá;RESEX;Reserva Extrativista;uso sustentável;1990;CR1 Porto Velho/RO;537.949;Amazônia;;;;;;; 273 | 0000.00.0230;RESEX do Baixo Juruá;RESEX;Reserva Extrativista;uso sustentável;2001;CR2 Manaus/AM;178.039;Amazônia;;;;;;; 274 | 0000.00.0231;RESEX do Batoque;RESEX;Reserva Extrativista;uso sustentável;2003;CR6 Cabedelo/PB;601;Caatinga;;;;;;; 275 | 0000.00.0232;RESEX do Cazumbá-Iracema;RESEX;Reserva Extrativista;uso sustentável;2002;CR1 Porto Velho/RO;750.922;Amazônia;;;;;;; 276 | 0000.00.1519;RESEX do Ciriaco;RESEX;Reserva Extrativista;uso sustentável;1992;CR4 Belém/PA;8.107;Amazônia;;;;;;; 277 | 0000.00.0240;RESEX do Extremo Norte do Tocantins;RESEX;Reserva Extrativista;uso sustentável;1992;CR4 Belém/PA;9.071;Cerrado;;111,7;;;;; 278 | 0000.00.0242;RESEX do Lago do Capanã Grande;RESEX;Reserva Extrativista;uso sustentável;2004;CR2 Manaus/AM;304.313;Amazônia;;;186,4;;;; 279 | 0000.00.0233;RESEX do Lago do Cuniã;RESEX;Reserva Extrativista;uso sustentável;1999;CR1 Porto Velho/RO;50.604;Amazônia;;;;;;; 280 | 0000.00.0234;RESEX do Mandira;RESEX;Reserva Extrativista;uso sustentável;2002;CR8 Rio de Janeiro/RJ;1.178;Mata Atlântica;;;;;;; 281 | 0000.00.0235;RESEX do Médio Juruá;RESEX;Reserva Extrativista;uso sustentável;1997;CR2 Manaus/AM;286.933;Amazônia;;;;;;; 282 | 0000.00.1606;RESEX do Médio Purus;RESEX;Reserva Extrativista;uso sustentável;2008;CR1 Porto Velho/RO;604.236;Amazônia;;;;;;; 283 | 0000.00.1520;RESEX do Quilombo Flexal;RESEX;Reserva Extrativista;uso sustentável;1992;CR4 Belém/PA;9.338;Amazônia;;;;;;; 284 | 0000.00.1518;RESEX do Rio Cajari;RESEX;Reserva Extrativista;uso sustentável;1990;CR4 Belém/PA;532.405;Amazônia;3.218,5;;19.531,7;27.080,1;;; 285 | 0000.00.0238;RESEX do Rio do Cautário;RESEX;Reserva Extrativista;uso sustentável;2001;CR1 Porto Velho/RO;75.125;Amazônia;;;;;;; 286 | 0000.00.0239;RESEX do Rio Jutaí;RESEX;Reserva Extrativista;uso sustentável;2002;CR2 Manaus/AM;275.516;Amazônia;;;;;;; 287 | 0000.00.0256;RESEX do Rio Ouro Preto;RESEX;Reserva Extrativista;uso sustentável;1990;CR1 Porto Velho/RO;204.633;Amazônia;;712,1;324,0;;;; 288 | 0000.00.0288;RESEX Gurupá-Melgaço;RESEX;Reserva Extrativista;uso sustentável;2006;CR4 Belém/PA;145.574;Amazônia;;;;;;; 289 | 0000.00.0241;RESEX Ipaú-Anilzinho;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;55.835;Amazônia;;81,3;;;;; 290 | 0000.00.1628;RESEX Ituxí;RESEX;Reserva Extrativista;uso sustentável;2008;CR1 Porto Velho/RO;776.330;Amazônia;;;;;;; 291 | 0000.00.0287;RESEX Lago do Cedro;RESEX;Reserva Extrativista;uso sustentável;2006;CR10 Cuiabá/MT;17.404;Cerrado;;;;;;; 292 | 0000.00.0243;RESEX Mãe Grande de Curuça;RESEX;Reserva Extrativista;uso sustentável;2002;CR4 Belém/PA;36.679;Amazônia;;;;;;; 293 | 0000.00.0244;RESEX Mapuá;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;93.748;Amazônia;;;;;;; 294 | 0000.00.0227;RESEX Maracanã;RESEX;Reserva Extrativista;uso sustentável;2002;CR4 Belém/PA;30.180;Amazônia;;;;;;; 295 | 0000.00.0247;RESEX Marinha AraÍ-Peroba;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;50.555;Amazônia;;;;;;; 296 | 0000.00.0248;RESEX Marinha Caeté-Taperaçu;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;42.490;Amazônia;;;;;;; 297 | 0000.00.3134;RESEX Marinha Cuinarana;RESEX;Reserva Extrativista;uso sustentável;2014;CR4 Belém/PA;11.037;Marinho-Costeiro;;;;;;; 298 | 0000.00.0245;RESEX Marinha da Baia de Iguape;RESEX;Reserva Extrativista;uso sustentável;2000;CR7 Porto Seguro/BA;10.083;Marinho-Costeiro;;;;;;; 299 | 0000.00.0246;RESEX Marinha da Lagoa do Jequiá;RESEX;Reserva Extrativista;uso sustentável;2001;CR6 Cabedelo/PB;10.204;Mata Atlântica;;;;;;; 300 | 0000.00.0249;RESEX Marinha de Gurupi-Piriá;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;72.790;Amazônia;;;;;;; 301 | 0000.00.0254;RESEX Marinha de Soure;RESEX;Reserva Extrativista;uso sustentável;2001;CR4 Belém/PA;29.579;Amazônia;;;;;;; 302 | 0000.00.0251;RESEX Marinha do Arraial do Cabo;RESEX;Reserva Extrativista;uso sustentável;1997;CR8 Rio de Janeiro/RJ;51.677;Mata Atlântica;;;;;;; 303 | 0000.00.0252;RESEX Marinha do Corumbau;RESEX;Reserva Extrativista;uso sustentável;2000;CR7 Porto Seguro/BA;89.598;Marinho-Costeiro;;;;;;; 304 | 0000.00.0225;RESEX Marinha do Delta do Parnaíba;RESEX;Reserva Extrativista;uso sustentável;2000;CR5 Parnaíba/PI;27.022;Cerrado;;63,6;;;;; 305 | 0000.00.3133;RESEX Marinha Mestre Lucindo;RESEX;Reserva Extrativista;uso sustentável;2014;CR4 Belém/PA;26.465;Marinho-Costeiro;;;;;;; 306 | 0000.00.3132;RESEX Marinha Mocapajuba;RESEX;Reserva Extrativista;uso sustentável;2014;CR4 Belém/PA;21.029;Marinho-Costeiro;;;;;;; 307 | 0000.00.0255;RESEX Marinha Pirajubaé;RESEX;Reserva Extrativista;uso sustentável;1992;CR9 Florianópolis/SC;1.712;Marinho-Costeiro;;;;;;; 308 | 0000.00.0250;RESEX Marinha Tracuateua;RESEX;Reserva Extrativista;uso sustentável;2005;CR4 Belém/PA;27.865;Amazônia;;;;;;; 309 | 0000.00.1809;RESEX Prainha do Canto Verde;RESEX;Reserva Extrativista;uso sustentável;2009;CR6 Cabedelo/PB;29.805;Marinho-Costeiro;;;;;;; 310 | 0000.00.1810;RESEX Renascer;RESEX;Reserva Extrativista;uso sustentável;2009;CR3 Santarém/PA;209.667;Amazônia;;;;372,5;;;294,6 311 | 0000.00.0280;RESEX Rio Iriri;RESEX;Reserva Extrativista;uso sustentável;2006;CR3 Santarém/PA;398.998;Amazônia;;;;;;; 312 | 0000.00.0283;RESEX Rio Unini;RESEX;Reserva Extrativista;uso sustentável;2006;CR2 Manaus/AM;849.693;Amazônia;;;;;;; 313 | 0000.00.1635;RESEX Rio Xingu;RESEX;Reserva Extrativista;uso sustentável;2008;CR3 Santarém/PA;303.005;Amazônia;;;;;;; 314 | 0000.00.0257;RESEX Riozinho da Liberdade;RESEX;Reserva Extrativista;uso sustentável;2005;CR1 Porto Velho/RO;324.906;Amazônia;;;;;;; 315 | 0000.00.0258;RESEX Riozinho do Anfrísio;RESEX;Reserva Extrativista;uso sustentável;2004;CR3 Santarém/PA;736.144;Amazônia;;;;;;; 316 | 0000.00.0259;RESEX Tapajós-Arapiuns;RESEX;Reserva Extrativista;uso sustentável;1998;CR3 Santarém/PA;677.521;Amazônia;;19,9;;;;; 317 | 0000.00.0282;RESEX Terra Grande-Pracuuba;RESEX;Reserva Extrativista;uso sustentável;2006;CR4 Belém/PA;194.870;Amazônia;;;;;;; 318 | 0000.00.0260;RESEX Verde Para Sempre;RESEX;Reserva Extrativista;uso sustentável;2004;CR3 Santarém/PA;1.289.380;Amazônia;;;22.933,5;699,0;;;1.397,4 319 | 0000.00.0219;REVIS das Veredas do Oeste Baiano;RVS;Refúgio de Vida Silvestre;proteção integral;2002;CR11 Lagoa Santa/MG;128.051;Cerrado;321,2;39.767,4;4.695,4;11.236,4;49.071,5;2.638,9;99,3 320 | 0000.00.1907;REVIS de Boa Nova;RVS;Refúgio de Vida Silvestre;proteção integral;2010;CR7 Porto Seguro/BA;15.024;Mata Atlântica;;96,5;;;;; 321 | 0000.00.1911;REVIS de Santa Cruz;RVS;Refúgio de Vida Silvestre;proteção integral;2010;CR7 Porto Seguro/BA;17.710;Marinho-Costeiro;;;;;;; 322 | 0000.00.1880;REVIS de Una;RVS;Refúgio de Vida Silvestre;proteção integral;2007;CR7 Porto Seguro/BA;23.424;Mata Atlântica;;;;;;; 323 | 0000.00.3432;REVIS do Arquipélago de Alcatrazes;RVS;Refúgio de Vida Silvestre;proteção integral;2016;CR8 Rio de Janeiro/RJ;67.364;Marinho-Costeiro;;;;;;; 324 | 0000.00.1813;REVIS do Rio dos Frades;RVS;Refúgio de Vida Silvestre;proteção integral;2007;CR7 Porto Seguro/BA;899;Mata Atlântica;;;;;;; 325 | 0000.00.0278;REVIS dos Campos de Palmas;RVS;Refúgio de Vida Silvestre;proteção integral;2006;CR9 Florianópolis/SC;16.594;Mata Atlântica;;109,5;3.249,5;;;; 326 | 0000.00.0190;REVIS Ilha dos Lobos;RVS;Refúgio de Vida Silvestre;proteção integral;2005;CR9 Florianópolis/SC;142;Marinho-Costeiro;;;;;;; 327 | -------------------------------------------------------------------------------- /docs/doubles.md: -------------------------------------------------------------------------------- 1 | # Test Doubles (ou Mocks para os íntimos) 2 | 3 | * Test Double não é Mock mas Mock é um Test Double 4 | * Dublês de Testes substituem objetos reais 5 | * Outro componente 6 | * Serviço 7 | * Banco de Dados 8 | 9 | ## Tipos de Dublês de Teste 10 | 11 | ### Dummy 12 | 13 | Objetos que podem circular quando necessário mas não tem nenhum tipo de implementação de teste e não será usado pela aplicação. 14 | 15 | ### Fake 16 | 17 | Objetos que, normalmente, tem implementação simplificada de uma determinada interface, que é adequada para teste mas não para produção. 18 | 19 | Exemplos de aplicação: arquivo com conteúdo para o teste, data e hora de criação de um registro. 20 | 21 | ### Stub 22 | 23 | Objetos que oferecem implementações com respostas semiprontas que são adequadas para os testes. 24 | 25 | Exemplos de aplicação: status de uma transação. 26 | 27 | ### Spies 28 | 29 | Objetos que oferecem implementações que guardam valores que foram passados e que podem ser usados pelos testes. 30 | 31 | Exemplos de aplicação: atualização ou configuração de um valor que precisa ser verificado. 32 | 33 | ### Mocks 34 | 35 | Objetos pré-programados para esperar chamadas específicas, número de vezes que uma chamada é feita e parâmetros e podem lançar exceções quando necessário. 36 | 37 | Exemplos de aplicação: verificar se todos os dados de uma lista foram enviados para o banco de dados, falha na conexão com um serviço. 38 | -------------------------------------------------------------------------------- /docs/revisao.md: -------------------------------------------------------------------------------- 1 | # Revisão 2 | 3 | ## Testes automatizados 4 | 5 | * Diferentes tipos de testes 6 | * Unitários 7 | * Integração 8 | * Funcionais 9 | * Outros 10 | 11 | ## Testes unitários 12 | 13 | * Testes de componentes (função, classe) 14 | * Garantir que cada parte isolada do software funciona corretamente 15 | * Mitigar problemas de lógica, detectando falhas cedo 16 | * Direcionar desenvolvimento pensando em entradas e saídas, condições de erro, fragmentação de código, maior cuidado com o comportamento do componente 17 | 18 | **NUNCA SE ESQUEÇA DISSO!** 19 | 20 | ![Teste unitário X Teste integrado](/static/img/unit-test.gif) 21 | 22 | ## Testes unitários X TDD 23 | 24 | * Testes escritos antes do código 25 | * Usado no XP (eXtreme Programming) e Coding Dojos Randori 26 | * Garantir que o código tenha testes (no test, no code) 27 | * Direcionar o desenvolvimento com refatoração de código, códigos mais enxutos 28 | 29 | ### Ciclo Global do TDD 30 | 31 | ![Ciclo Global do TDD](/static/img/TDD_Global_Lifecycle.png) 32 | -------------------------------------------------------------------------------- /docs/unittest.md: -------------------------------------------------------------------------------- 1 | # Unittest: testes automatizados usando Just Python 2 | 3 | * Módulo *Built-in* do Python para testes unitários 4 | * Inspirado pelo JUnit, framework Java de testes unitários 5 | 6 | ## unittest.TestCase 7 | 8 | * Cenário único, com determinada configuração para o teste. 9 | * Criação de subclasses de `unittest.TestCase` ou `unittest.FunctionTestCase` 10 | 11 | ## unittest.TestSuite 12 | 13 | * Coleção de TestCases e outros TestSuites 14 | * Organizar testes que devem ser executados juntos 15 | 16 | ## Mão na massa 1: Como montar um caso de teste 17 | 18 | Vamos montar um caso de teste de algo já implementado, para já irmos criando memória muscular. Também para vermos que é possível criar testes para o que já está desenvolvido, certo? ;-) 19 | 20 | Nosso primeiro objeto de teste será o `str`! 21 | 22 | _tests/test_string.py_ 23 | ```python 24 | import unittest 25 | 26 | 27 | class TestStringMethods(unittest.TestCase): 28 | 29 | def test_upper(self): 30 | self.assertEqual('python'.upper(), 'PYTHON') 31 | 32 | def test_isupper(self): 33 | self.assertTrue('PYTHON'.isupper()) 34 | self.assertFalse('Python'.isupper()) 35 | 36 | def test_split(self): 37 | s = 'Python Brasil [15]' 38 | self.assertEqual(s.split(), ['Python', 'Brasil', '[15]']) 39 | with self.assertRaises(TypeError): 40 | s.split(3) 41 | 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | 46 | ``` 47 | 48 | E para rodá-lo, basta executar o seguinte comando: 49 | 50 | ```bash 51 | python -m unittest -v tests/test_string.py 52 | ``` 53 | 54 | 55 | ## Mão na massa 2: Iniciando nosso projeto com testes (e TDD!) 56 | 57 | Agora vamos criar um projeto do zero, usando TDD para nos guiar. Vamos utilizar este projeto para o restante do tutorial, tentando explorar casos de uso reais (ou mais próximos deles). 58 | 59 | Nossa aplicação vai baixar um arquivo sobre os incêndios em Unidades de Conservação Federais entre 2012 e 2018 e vai armazenar os dados em um banco de dados, que será disponibilizado para análise. 60 | 61 | O arquivo está em formato CSV e se encontra no link do Instituto Chico Mentes: http://www.icmbio.gov.br/acessoainformacao/images/stories/PDA/Planilhas/Planilhas_CSV/DIMIF-queima.csv, com os seguintes dados: 62 | - Código CNUC 63 | - Nome da UC 64 | - Categoria da UC: sigla federal 65 | - Categoria da UC: nomenclatura nacional 66 | - Grupo de Proteção 67 | - Ano de criação 68 | - Coordenação Regional do ICMBio 69 | - Área estimada da UC (ha) 70 | - Bioma referencial 71 | - Área queimada em 2018 72 | - Área queimada em 2017 73 | - Área queimada em 2016 74 | - Área queimada em 2015 75 | - Área queimada em 2014 76 | - Área queimada em 2013 77 | - Área queimada em 2012 78 | 79 | O armazenamento dos dados será feito através de um serviço externo, que tem uma REST API. 80 | 81 | Vamos começar montando a estrutura básica de um projeto: 82 | 83 | ```bash 84 | my_project 85 | ├── tests 86 | │   ├── __init__.py 87 | │   └── test_app.py 88 | ├── README.md 89 | └── setup.py 90 | ``` 91 | 92 | Agora, defina o conteúdo do `setup.py`: 93 | 94 | ```python 95 | import setuptools 96 | import pathlib 97 | 98 | readme_path = pathlib.Path("README.md") 99 | with readme_path.open() as f: 100 | README = f.read() 101 | 102 | setuptools.setup( 103 | name="my_project", 104 | version="0.1", 105 | author="Paty Morimoto", 106 | author_email="excermori@yahoo.com.br", 107 | description="", 108 | long_description=README, 109 | long_description_content_type="text/markdown", 110 | license="GNU General Public License v3.0", 111 | packages=setuptools.find_packages( 112 | exclude=["*.tests", "*.tests.*", "tests.*", "tests"] 113 | ), 114 | include_package_data=True, 115 | python_requires=">=3.7", 116 | test_suite="tests", 117 | classifiers=[ 118 | "Development Status :: 2 - Beta", 119 | "Environment :: Other Environment", 120 | "Programming Language :: Python :: 3.7", 121 | "Operating System :: OS Independent", 122 | ], 123 | entry_points="""\ 124 | [console_scripts] 125 | my_app=core.app:execute 126 | """, 127 | ) 128 | ``` 129 | 130 | ... e a nossa classe de teste: 131 | 132 | ```python 133 | import json 134 | from unittest import TestCase, main 135 | 136 | from core import app 137 | 138 | 139 | class TestExecute(TestCase): 140 | def setUp(self): 141 | self.result = app.execute() 142 | 143 | def test_returns_hello_app(self): 144 | self.assertEqual(self.result, "Bem vindo ao Tutorial de Mocks!") 145 | 146 | 147 | if __name__ == '__main__': 148 | main() 149 | ``` 150 | 151 | Pronto! A gente já consegue rodar o nosso primeiro teste com TDD! 152 | 153 | ```bash 154 | python setup.py test 155 | ``` 156 | 157 | E ver nosso primeiro erro: 158 | 159 | ```bash 160 | [...] 161 | 162 | test_returns_hello_app (tests.test_app.TestExecute) ... ERROR 163 | 164 | ====================================================================== 165 | ERROR: test_returns_hello_app (tests.test_app.TestExecute) 166 | ---------------------------------------------------------------------- 167 | Traceback (most recent call last): 168 | File ".../my_project/tests/test_app.py", line 10, in setUp 169 | self.result = app.execute() 170 | AttributeError: module 'core.app' has no attribute 'execute' 171 | 172 | ---------------------------------------------------------------------- 173 | Ran 1 test in 0.000s 174 | 175 | FAILED (errors=1) 176 | Test failed: 177 | error: Test failed: 178 | ``` 179 | 180 | Vamos corrigindo _ERROR_, até começarem a ocorrer _FAIL_ e, finalmente, ter nossa implementação com o teste rodando. Ao final desta primeira etapa, teremos esta árvore de projeto: 181 | 182 | ```bash 183 | my_project 184 | ├── core 185 | │   ├── app.py 186 | │   └── __init__.py 187 | ├── tests 188 | │   ├── __init__.py 189 | │   └── test_app.py 190 | ├── README.md 191 | └── setup.py 192 | ``` 193 | -------------------------------------------------------------------------------- /docs/unittest_mock.md: -------------------------------------------------------------------------------- 1 | # _unittest.mock_ 2 | 3 | * Biblioteca *Built-in* de Test Doubles 4 | * Incorporada desde a versão 3.3 5 | * Oferece os recursos básicos para testes unitários 6 | * Baseado no padrão *Arrange-Act-Assert* 7 | 8 | ## Classe _Mock()_ 9 | * Permite a criação de Dublês de Teste de forma simples 10 | * Cria todos os atributos e métodos conforme são usados 11 | 12 | 13 | #### Exemplo de uso do _Mock_ 14 | ```python 15 | import json 16 | from unittest import mock 17 | from urllib.request import urlopen 18 | 19 | class ContaDaInternet: 20 | def obtem_status(): 21 | token = "ad18ce48280b0ab4cd19e719bec348b82e19ee56f05af78c9aef6d7f5bc444fd" 22 | response = urlopen( 23 | f"https://provedordeinternet.com.br/conta/{token}/?status") 24 | if response.status == 200: 25 | resp_json = json.loads(response.read()) 26 | return resp_json.get("status") 27 | 28 | 29 | conta = ContaDaInternet() 30 | conta.obtem_status = mock.Mock(return_value="Paga") 31 | conta.obtem_status() 32 | ``` 33 | 34 | 35 | ### Mock.return_value 36 | * Permite definir o retorno __fixo__ de: 37 | * uma chamada de função ou método 38 | * de uma instanciação de classe 39 | * de um atributo 40 | * de uma propriedade 41 | 42 | 43 | ## Classe _MagicMock()_ 44 | * Subclasse de _Mock_, com o mesmo construtor 45 | * Todos os _magic methods_ são pré-criados e prontos para uso. Consulte a documentação para saber os valores de retorno padrão de cada método mágico. 46 | 47 | 48 | ## Problema: baixar o arquivo CSV no link 49 | 50 | O `execute()` terá que acessar o link do site para gravar o arquivo CSV. Como o link pode mudar, vamos usar uma variável em um arquivo de configuração. Assim, é só alterar a configuração. Podemos pensar nos seguintes passos para realizar a tarefa: 51 | 52 | * Pegar link em config.py 53 | * HTTP GET no link 54 | * Ex: `urlopen(config.INCENDIOS_CSV_FILE_LINK)` 55 | 56 | E como vou saber se o urlopen foi executado corretamente, passando a URL certa? 57 | 58 | 59 | ### _mock.patch(target, new=DEFAULT, **kwargs)_ 60 | 61 | * Pode ser usado decorando uma método de teste, uma classe de teste ou em um context manager 62 | * O _target_ deve ser uma string com o caminho de import do módulo/objeto. Ex: 'package.module.ClassName' 63 | * Se _new_ não é informado, o objeto _target_ é substituído com um _MagicMock_ 64 | 65 | Então, vamos ao `test_app.py` 66 | 67 | ```python 68 | [...] 69 | 70 | class TestExecuteOK(TestCase): 71 | def setUp(self): 72 | with mock.patch('core.app.urlopen') as self.mock_urlopen: 73 | self.result = app.execute() 74 | [...] 75 | def test_gets_csvfile_from_urllink_in_config(self): 76 | self.mock_urlopen.assert_called_with(config.INCENDIOS_CSV_FILE_LINK) 77 | 78 | [...] 79 | ``` 80 | 81 | Estamos usando primeiro o _patch_ em um context manager, o que garante que somente neste momento o _urlopen_ do _core.app_ será substituído. 82 | 83 | Rode o teste e corrija os erros até que a falha ocorra: 84 | 85 | ```bash 86 | ====================================================================== 87 | FAIL: test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) 88 | ---------------------------------------------------------------------- 89 | Traceback (most recent call last): 90 | File "my_project/tests/test_app.py", line 16, in test_gets_csvfile_from_urllink_in_config 91 | self.mock_urlopen.assert_called_once_with(config.INCENDIOS_CSV_FILE_LINK) 92 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 844, in assert_called_once_with 93 | raise AssertionError(msg) 94 | AssertionError: Expected 'urlopen' to be called once. Called 0 times. 95 | 96 | ---------------------------------------------------------------------- 97 | 98 | ``` 99 | 100 | Agora é hora de implementar o objeto do teste: 101 | 102 | ```python 103 | 104 | from urllib.request import urlopen 105 | 106 | from . import config 107 | 108 | 109 | def execute(): 110 | msg = "Bem vindo ao Tutorial de Mocks!" 111 | urlopen(config.INCENDIOS_CSV_FILE_LINK) 112 | return msg 113 | 114 | ``` 115 | 116 | Rodando os testes novamente, não deve haver mais falhas. 117 | 118 | ```bash 119 | test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) ... ok 120 | test_returns_hello_app (tests.test_app.TestExecuteOK) ... ok 121 | 122 | ---------------------------------------------------------------------- 123 | Ran 2 tests in 0.002s 124 | 125 | OK 126 | ``` 127 | 128 | Neste nosso exemplo, também poderíamos usar o _patch_ como decorador: 129 | 130 | ```python 131 | [...] 132 | 133 | class TestExecuteOK(TestCase): 134 | @mock.patch('core.app.urlopen') 135 | def setUp(self, mock_urlopen): 136 | self.mock_urlopen = mock_urlopen 137 | self.result = app.execute() 138 | [...] 139 | def test_gets_csvfile_from_urllink_in_config(self): 140 | self.mock_urlopen.assert_called_once_with(config.INCENDIOS_CSV_FILE_LINK) 141 | 142 | [...] 143 | ``` 144 | 145 | Ou ainda criar um _patcher_, usando o `start()` e `stop()`: 146 | 147 | ```python 148 | [...] 149 | 150 | class TestExecuteOK(TestCase): 151 | @classmethod 152 | def setUpClass(cls): 153 | cls.mock_urlopen_patcher = mock.patch('core.app.urlopen') 154 | cls.mock_urlopen = cls.mock_urlopen_patcher.start() 155 | 156 | @classmethod 157 | def tearDownClass(cls): 158 | cls.mock_urlopen_patcher.stop() 159 | 160 | def setUp(self): 161 | self.result = app.execute() 162 | [...] 163 | def test_gets_csvfile_from_urllink_in_config(self): 164 | self.mock_urlopen.assert_called_once_with(config.INCENDIOS_CSV_FILE_LINK) 165 | 166 | [...] 167 | ``` 168 | 169 | ## Problema: salvar o arquivo CSV baixado 170 | 171 | O `execute()` deverá salvar o arquivo CSV baixado em disco. Para isso, podemos: 172 | 173 | * Abrir um arquivo 174 | * Escrever o conteúdo recebido no arquivo 175 | 176 | Vamos utilizar aqui `pathlib` para manipular o arquivo CSV. Nesta implementação, vamos usar especificamente `pathlib.Path`. 177 | 178 | ```python 179 | [...] 180 | 181 | class TestExecuteOK(TestCase): 182 | @classmethod 183 | def setUpClass(cls): 184 | [...] 185 | cls.mock_path_patcher = mock.patch.object( 186 | app.pathlib, 'Path', spec=app.pathlib.Path, name="MockPath" 187 | ) 188 | cls.mock_path = cls.mock_path_patcher.start() 189 | 190 | @classmethod 191 | def tearDownClass(cls): 192 | [...] 193 | cls.mock_path_patcher.stop() 194 | 195 | def setUp(self): 196 | self.result = app.execute() 197 | 198 | [...] 199 | 200 | def test_creates_path_to_csvfile(self): 201 | self.mock_path.assert_called_with("dados_incendios_cf.csv") 202 | 203 | def test_writes_csvfile_content(self): 204 | self.mock_path.return_value.write_text.assert_called_with( 205 | self.mock_urlopen.return_value.read.return_value.decode.return_value 206 | ) 207 | 208 | [...] 209 | ``` 210 | 211 | 212 | ### _mock.patch.object(target, attribute, new=DEFAULT, **kwargs)_ 213 | 214 | Pode ser usado decorando uma método de teste, uma classe de teste ou em um context manager 215 | 216 | O _target_ deve ser o caminho de import do módulo que contém o objeto a ser simulado. Atenção aqui que este caminho não é uma string! 217 | 218 | O _attribute_ deve ser uma string com o nome do módulo/objeto a ser simulado 219 | 220 | Se _new_ não é informado, o _attribute_ é substituído com um _MagicMock_ 221 | 222 | 223 | ### _Mock spec e spec_set_ 224 | 225 | #### _spec_ 226 | 227 | O _spec_ é um argumento na definição de um dublê de teste. Pode ser uma lista de strins ou um objeto existente (uma classe ou instancia) que atua como a especificação para o dublê. Se um objeto é passado, então uma lista de strings é formada pela chamada do _dir()_ do objeto, excluindo os atributos e métodos mágicos não suportados. Acessando qualquer atributo ou método que não estiver na lista resultará na exceção _AttributeError_. 228 | 229 | Um outro detalhe é que usando o _spec_ com um objeto, o atributo mágico *\_\_class\_\_* retorna a classe definida no _spec_. Isso permite que, por exemplo, a função _isinstance()_ funcione. 230 | 231 | 232 | Rodando os testes, devem ocorrer os erros: 233 | 234 | ```bash 235 | ====================================================================== 236 | FAIL: test_creates_path_to_csvfile (tests.test_app.TestExecuteOK) 237 | ---------------------------------------------------------------------- 238 | Traceback (most recent call last): 239 | File "my_project/tests/test_app.py", line 37, in test_creates_path_to_csvfile 240 | self.mock_path.assert_called_with("dados_incendios_cf.csv") 241 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 825, in assert_called_with 242 | raise AssertionError('Expected call: %s\nNot called' % (expected,)) 243 | AssertionError: Expected call: open('dados_incendios_cf.csv') 244 | Not called 245 | 246 | ====================================================================== 247 | FAIL: test_writes_csvfile_content (tests.test_app.TestExecuteOK) 248 | ---------------------------------------------------------------------- 249 | Traceback (most recent call last): 250 | File "my_project/tests/test_app.py", line 40, in test_writes_csvfile_content 251 | self.mock_path.return_value.write_text.assert_called_with(self.mock_urlopen()) 252 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 825, in assert_called_with 253 | raise AssertionError('Expected call: %s\nNot called' % (expected,)) 254 | AssertionError: Expected call: write() 255 | Not called 256 | 257 | ---------------------------------------------------------------------- 258 | 259 | ``` 260 | 261 | E agora é implementar para o teste passar: 262 | 263 | ```python 264 | 265 | [...] 266 | 267 | def execute(): 268 | 269 | [...] 270 | csvfile = pathlib.Path("dados_incendios_cf.csv") 271 | csvfile.write_text(response.read().decode("utf-8")) 272 | return msg 273 | 274 | ``` 275 | 276 | Agora os testes devem passar. 277 | 278 | ```bash 279 | test_creates_path_to_csvfile (tests.test_app.TestExecuteOK) ... ok 280 | test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) ... ok 281 | test_returns_hello_app (tests.test_app.TestExecuteOK) ... ok 282 | test_writes_csvfile_content (tests.test_app.TestExecuteOK) ... ok 283 | 284 | ---------------------------------------------------------------------- 285 | Ran 4 tests in 0.007s 286 | 287 | OK 288 | ``` 289 | 290 | ### _Mock autospec_ 291 | 292 | É uma outra forma de utilizar o spec, checando, inclusive, a assinatura dos métodos, por exemplo. Para usá-lo, basta definir `autospec=True`. 293 | 294 | 295 | ## Problema: arquivo CSV indisponível 296 | 297 | O `execute()` deverá salvar o arquivo CSV somente se conseguir recebê-lo. Então, para que a aplicação informe corretamente que o CSV está indisponível, é necessário verificar a resposta HTTP. Vamos então: 298 | 299 | * Ao fazer a requisição HTTP do arquivo CSV do link, verificar se ocorre erro 300 | * Se ocorrer erro, exibir mensagem com detalhes do problema e não tentar gravar o arquivo 301 | 302 | E como é possível simular um erro, uma exceção? 303 | 304 | 305 | ### Mock.side_effect 306 | Permite definir um comportamento ao chamar um objeto, que pode ser: 307 | * o lançamento de uma exceção 308 | * retornos diferentes a cada chamada, através da definição de uma lista (ou tupla) 309 | * uma função a ser executada 310 | 311 | 312 | Então vamos ao teste: 313 | 314 | ```python 315 | [...] 316 | 317 | class TestExecuteErrors(TestCase): 318 | @mock.patch('core.app.urlopen') 319 | @mock.patch('core.app.pathlib.Path') 320 | def test_url_does_not_exist_should_not_create_path(self, MockPath, mock_urlopen): 321 | mock_urlopen.side_effect = urllib.error.URLError( 322 | "[Errno -2] Name or service not known" 323 | ) 324 | 325 | self.result = app.execute() 326 | 327 | self.assertEqual( 328 | self.result, 329 | "Could not get CSV file: " 330 | ) 331 | MockPath.assert_not_called() 332 | 333 | [...] 334 | ``` 335 | 336 | Rodando os testes, o seguinte erro deve ser apresentado: 337 | 338 | ```bash 339 | ====================================================================== 340 | ERROR: test_url_does_not_exist_should_not_create_path (tests.test_app.TestExecuteErrors) 341 | ---------------------------------------------------------------------- 342 | Traceback (most recent call last): 343 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 1209, in patched 344 | return func(*args, **keywargs) 345 | File "my_project/tests/test_app.py", line 49, in test_url_does_not_exist_should_not_create_path 346 | self.result = app.execute() 347 | File "my_project/core/app.py", line 17, in execute 348 | response = urlopen(config.INCENDIOS_CSV_FILE_LINK) 349 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 965, in __call__ 350 | return _mock_self._mock_call(*args, **kwargs) 351 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 1025, in _mock_call 352 | raise effect 353 | urllib.error.URLError: 354 | 355 | ---------------------------------------------------------------------- 356 | 357 | ``` 358 | 359 | 360 | Implementando para o teste passar... 361 | 362 | ```python 363 | 364 | [...] 365 | 366 | def execute(): 367 | msg = "Bem vindo ao Tutorial de Mocks!" 368 | try: 369 | response = urlopen(config.INCENDIOS_CSV_FILE_LINK) 370 | except URLError as exc: 371 | msg = f"Could not get CSV file: {exc}" 372 | else: 373 | csvfile = pathlib.Path("dados_incendios_cf.csv") 374 | csvfile.write_text(response) 375 | return msg 376 | 377 | ``` 378 | 379 | ... e eles devem passar! 380 | 381 | ```bash 382 | test_url_does_not_exist_should_not_create_path (tests.test_app.TestExecuteErrors) ... ok 383 | test_creates_path_to_csvfile (tests.test_app.TestExecuteOK) ... ok 384 | test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) ... ok 385 | test_returns_hello_app (tests.test_app.TestExecuteOK) ... ok 386 | test_writes_csvfile_content (tests.test_app.TestExecuteOK) ... ok 387 | 388 | ---------------------------------------------------------------------- 389 | Ran 5 tests in 0.007s 390 | 391 | OK 392 | ``` 393 | 394 | 395 | ## Problema: envio dos dados para serviço externo 396 | 397 | O `execute()` deverá ler o arquivo CSV e enviar os dados para um serviço externo, que armazenará e cuidará de disponibilizar os dados para usuários. Foi determinado que é importante organizar os dados por: 398 | * categoria da UC 399 | * grupo de proteção 400 | * bioma referencial 401 | 402 | Portanto, podemos definir nosso domínio: 403 | 404 | * UnidadeConservacao 405 | * Categoria 406 | * GrupoProtecao 407 | * BiomaReferencial 408 | 409 | A API REST para o serviço externo disponibiliza os seguintes endpoints: 410 | 411 | * `PUT /entity`: cria entidade com a lista de campos informados, cada um com seu tipo 412 | * `POST /add`: adiciona dados para a uma entidade 413 | 414 | Vamos ao teste! 415 | 416 | ```python 417 | [...] 418 | 419 | @mock.patch('core.app.urlopen', autospec=True) 420 | @mock.patch('core.app.Request', autospec=True) 421 | class TestServiceAdapter(TestCase): 422 | @classmethod 423 | def setUpClass(cls): 424 | cls.headers = { 425 | "Content-Type": "application/json", 426 | } 427 | cls.service_config = { 428 | "host": "http://datastoreservice:8000", 429 | } 430 | cls.adapter = app.ServiceAdapter(**cls.service_config) 431 | 432 | def test_init(self, MockRequest, mock_urlopen): 433 | self.assertEqual(self.adapter._host, self.service_config["host"]) 434 | self.assertEqual(self.adapter._headers, {"Content-Type": "application/json"}) 435 | 436 | def test_create_entity(self, MockRequest, mock_urlopen): 437 | fields = { 438 | "field_1": { 439 | "type": "string", 440 | "mandatory": True, 441 | }, 442 | "field_2": { 443 | "type": "integer", 444 | "mandatory": True, 445 | }, 446 | "field_3": { 447 | "type": "date", 448 | "mandatory": False, 449 | }, 450 | "field_4": { 451 | "type": "boolean", 452 | "mandatory": False, 453 | }, 454 | } 455 | self.adapter.create_entity(name="test", fields=fields) 456 | MockRequest.assert_called_once_with( 457 | f'{self.service_config["host"]}/entity', 458 | data=fields, 459 | headers=self.headers, 460 | method="PUT", 461 | ) 462 | mock_urlopen.assert_called_once_with(MockRequest.return_value) 463 | 464 | def test_add_data(self, MockRequest, mock_urlopen): 465 | data = { 466 | "field_1": "APA Costa das Algas", 467 | "field_2": "integer", 468 | "field_4": "boolean", 469 | } 470 | self.adapter.add_data(name="test", data=data) 471 | MockRequest.assert_called_once_with( 472 | f'{self.service_config["host"]}/add', 473 | data=data, 474 | headers=self.headers, 475 | method="POST", 476 | ) 477 | mock_urlopen.assert_called_once_with(MockRequest.return_value) 478 | 479 | def test_fetch_data(self, MockRequest, mock_urlopen): 480 | data_dict = { 481 | "field_1": "APA Costa das Algas", 482 | "field_2": "integer", 483 | "field_4": "boolean", 484 | } 485 | data = str(data_dict).encode("utf-8") 486 | mock_handler = mock.Mock() 487 | mock_handler.read.return_value = data 488 | MockResponse = mock.MagicMock() 489 | MockResponse.__enter__.return_value = mock_handler 490 | mock_urlopen.return_value = MockResponse 491 | 492 | result = self.adapter.fetch_data(name="test", id="1234") 493 | 494 | self.assertIsNotNone(result) 495 | self.assertEqual(result, data) 496 | mock_urlopen.assert_called_once_with(f'{self.service_config["host"]}/test/1234') 497 | 498 | [...] 499 | ``` 500 | 501 | Antes da implementação, os testes devem resultar em erros: 502 | 503 | ```bash 504 | ====================================================================== 505 | ERROR: setUpClass (tests.test_app.TestServiceAdapter) 506 | ---------------------------------------------------------------------- 507 | Traceback (most recent call last): 508 | File "my_project/tests/test_app.py", line 21, in setUpClass 509 | cls.adapter = app.ServiceAdapter(**cls.service_config) 510 | AttributeError: module 'core.app' has no attribute 'ServiceAdapter' 511 | 512 | ---------------------------------------------------------------------- 513 | ``` 514 | 515 | Depois da implementação... 516 | 517 | ```python 518 | class ServiceAdapter: 519 | def __init__(self, **config): 520 | self._host = config.get("host") 521 | self._headers = {"Content-Type": "application/json"} 522 | 523 | def create_entity(self, name, fields): 524 | req = Request( 525 | self._host + "/entity", 526 | data=fields, 527 | headers=self._headers, 528 | method="PUT", 529 | ) 530 | response = urlopen(req) 531 | 532 | def add_data(self, name, data): 533 | req = Request( 534 | self._host + "/add", 535 | data=data, 536 | headers=self._headers, 537 | method="POST", 538 | ) 539 | response = urlopen(req) 540 | 541 | def fetch_data(self, name, id): 542 | response = urlopen(f'{self._host}/{name}/{id}') 543 | ``` 544 | 545 | ... os testes passam! 546 | 547 | ```bash 548 | test_url_does_not_exist_should_not_create_path (tests.test_app.TestExecuteErrors) ... ok 549 | test_creates_path_to_csvfile (tests.test_app.TestExecuteOK) ... ok 550 | test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) ... ok 551 | test_gets_service_adapter (tests.test_app.TestExecuteOK) ... ok 552 | test_returns_hello_app (tests.test_app.TestExecuteOK) ... ok 553 | test_writes_csvfile_content (tests.test_app.TestExecuteOK) ... ok 554 | test_add_data (tests.test_app.TestServiceAdapter) ... ok 555 | test_create_entity (tests.test_app.TestServiceAdapter) ... ok 556 | test_init (tests.test_app.TestServiceAdapter) ... ok 557 | 558 | ---------------------------------------------------------------------- 559 | Ran 9 tests in 0.045s 560 | 561 | OK 562 | ``` 563 | 564 | E agora a gente faz as alterações no `execute()`. Primeiro, os testes: 565 | 566 | ```python 567 | [...] 568 | 569 | class TestExecuteOK(TestCase): 570 | @classmethod 571 | def setUpClass(cls): 572 | [...] 573 | 574 | cls.mock_service_adapter_patcher = mock.patch( 575 | 'core.app.ServiceAdapter', 576 | name="MockServiceAdapter", 577 | ) 578 | cls.mock_service_adapter = cls.mock_service_adapter_patcher.start() 579 | cls.service_config = { 580 | "host": "https://localhost:8888", 581 | } 582 | cls.mock_service_config_patcher = mock.patch.dict( 583 | 'core.config.SERVICE_CONFIG', **cls.service_config 584 | ) 585 | cls.mock_service_config = cls.mock_service_config_patcher.start() 586 | 587 | @classmethod 588 | def tearDownClass(cls): 589 | [...] 590 | 591 | cls.mock_service_adapter_patcher.stop() 592 | cls.mock_service_config_patcher.stop() 593 | 594 | def setUp(self): 595 | self.result = app.execute() 596 | 597 | def test_gets_service_adapter(self): 598 | self.mock_service_adapter.assert_called_with(**self.service_config) 599 | 600 | [...] 601 | ``` 602 | 603 | ... que, ao ser rodado... 604 | 605 | ```bash 606 | ====================================================================== 607 | FAIL: test_gets_service_adapter (tests.test_app.TestExecuteOK) 608 | ---------------------------------------------------------------------- 609 | Traceback (most recent call last): 610 | File "my_project/tests/test_app.py", line 137, in test_gets_service_adapter 611 | self.mock_service_adapter.assert_called_with(**self.service_config) 612 | File "/home/username/.pyenv/versions/3.7.4/lib/python3.7/unittest/mock.py", line 825, in assert_called_with 613 | raise AssertionError('Expected call: %s\nNot called' % (expected,)) 614 | AssertionError: Expected call: MockServiceAdapter(host='https://localhost:8888') 615 | Not called 616 | 617 | ---------------------------------------------------------------------- 618 | ``` 619 | 620 | Aí, implementamos: 621 | 622 | ```python 623 | def execute(): 624 | [...] 625 | else: 626 | csvfile = pathlib.Path("dados_incendios_cf.csv") 627 | csvfile.write_text(response) 628 | adapter = ServiceAdapter(**config.SERVICE_CONFIG) 629 | return msg 630 | ``` 631 | 632 | E os testes passam! 633 | 634 | ```bash 635 | test_url_does_not_exist_should_not_create_path (tests.test_app.TestExecuteErrors) ... ok 636 | test_creates_path_to_csvfile (tests.test_app.TestExecuteOK) ... ok 637 | test_gets_csvfile_from_urllink_in_config (tests.test_app.TestExecuteOK) ... ok 638 | test_gets_service_adapter (tests.test_app.TestExecuteOK) ... ok 639 | test_returns_hello_app (tests.test_app.TestExecuteOK) ... ok 640 | test_writes_csvfile_content (tests.test_app.TestExecuteOK) ... ok 641 | test_add_data (tests.test_app.TestServiceAdapter) ... ok 642 | test_create_entity (tests.test_app.TestServiceAdapter) ... ok 643 | test_fetch_data (tests.test_app.TestServiceAdapter) ... ok 644 | test_init (tests.test_app.TestServiceAdapter) ... ok 645 | 646 | ---------------------------------------------------------------------- 647 | Ran 10 tests in 0.097s 648 | 649 | OK 650 | ``` 651 | 652 | 653 | ## configure_mock 654 | 655 | Permite definir um dicionário com a cadeia de `return_value` de chamadas e retornar um outro objeto _Mock_ 656 | 657 | ```python 658 | >>> class Something: 659 | ... def __init__(self): 660 | ... self.backend = BackendProvider() 661 | ... def method(self): 662 | ... response = self.backend.get_endpoint('foobar').create_call('spam', 'eggs').start_call() 663 | ... # more code 664 | ``` 665 | 666 | Olha o tamanho da linha necessária! 667 | 668 | ```python 669 | mock_backend.get_endpoint.return_value.create_call.return_value.start_call.return_value = mock_response 670 | ``` 671 | 672 | Usando o _Mock.configure_mock()_: 673 | 674 | ```python 675 | >>> something = Something() 676 | >>> mock_response = Mock(spec=open) 677 | >>> mock_backend = Mock() 678 | >>> config = {'get_endpoint.return_value.create_call.return_value.start_call.return_value': mock_response} 679 | >>> mock_backend.configure_mock(**config) 680 | ``` 681 | 682 | 683 | 684 | ## Deletar atributos 685 | 686 | Objetos Mock criam os atributos conforme a utilização deles, o que permite simular objetos de qualquer tipo. Porém, às vezes precisamos da ausência de um atributo. Para isso, podemos deletar o atributo com `del` dessa forma: 687 | 688 | ```python 689 | >>> mock = MagicMock() 690 | >>> hasattr(mock, 'is_python_brasil') 691 | True 692 | >>> del mock.is_python_brasil 693 | >>> hasattr(mock, 'is_python_brasil') 694 | False 695 | ``` 696 | -------------------------------------------------------------------------------- /static/img/TDD_Global_Lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patymori/mock-testes-tutorial/b235a79a5c8c8dcb991f4393d7d7c3ec41a92562/static/img/TDD_Global_Lifecycle.png -------------------------------------------------------------------------------- /static/img/unit-test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patymori/mock-testes-tutorial/b235a79a5c8c8dcb991f4393d7d7c3ec41a92562/static/img/unit-test.gif --------------------------------------------------------------------------------