Integration Tests
Integration tests are implemented in the top level application (main.py).
To perorm a test, run main with options that specify which type of test to run and where to find the data for the test.
See the documentation for main.py for details and examples.
Unit Tests
If a module has unit tests they are included in the source file.
Tests are defined at the end of the file, in a class that has a name that starts with Test.
For example, project.py defines a class named Project, and at the end of the file is another class named TestProject.
A test class defines a series of static methods that have names beginning with test.
These methods are run in order.
To run tests for a module, open a terminal window and cd to the top level folder.
Then type a command that runs pytest, including the name of the module to test:
$ pytest src/tidegates/project.py
It's also possible to run all the tests with a single shell command:
$ pytest src/tidegates/*.py
TestProject
Source code in src/tidegates/project.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
test_load()
staticmethod
Load the test data frame, expect to find 6 rows, with single letter barrier IDs
src/tidegates/project.py
84 85 86 87 88 89 90 91 92 93 | |
test_map_info()
staticmethod
The frame with map information should have 5 columns
src/tidegates/project.py
105 106 107 108 109 110 111 112 113 | |
test_regions()
staticmethod
The list of region names should be sorted from north to south
src/tidegates/project.py
95 96 97 98 99 100 101 102 103 | |
test_targets()
staticmethod
There should be two sets of targets, each with 10 entries, and one entry for each target in the map.
src/tidegates/project.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
TestTargets
Source code in src/tidegates/targets.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
test_TNC_columns()
staticmethod
Make sure the column names in the Target objects are the same as the column names in the data file
src/tidegates/targets.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
TestOP
Source code in src/tidegates/optipass.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
test_budget_formats()
staticmethod
Test the function that generates budget labels.
src/tidegates/optipass.py
586 587 588 589 590 591 592 593 | |
test_example_1()
staticmethod
Test the OPResults class by collecting results for Example 1 from the OptiPass User Manual.
src/tidegates/optipass.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
test_example_4()
staticmethod
Same as test_example_1, but using Example 4, which has two restoration targets.
src/tidegates/optipass.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
test_generate_frame()
staticmethod
Test the structure of a frame that will be printed as a 'barrier file' for input to OptiPass
src/tidegates/optipass.py
481 482 483 484 485 486 487 488 489 490 491 492 493 | |
test_instantiate_object()
staticmethod
Test the OP constructor.
src/tidegates/optipass.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
test_potential_habitat_1()
staticmethod
Test the method that computes potential habitat, using the results genearated for Example 1 in the OptiPass manual.
src/tidegates/optipass.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
test_potential_habitat_4()
staticmethod
Same as test_potential_habitat_1, but using Example 4, with two restoration targets
src/tidegates/optipass.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |