Unit Tests
Unit testing is done with pytest
.
To run all the tests, simply cd
to the top level directory and type this shell command:
$ pytest
The tests are all in the tests
directory:
test_main.py
has functions that test each of the paths defined inmain.py
test_optipass.py
has functions that test the interface to OptiPass
You can run one set of tests by including the file name in the shell command, e.g.
$ pytest test/test_optipass.py
Tests for main.py
test_projects()
Make sure the demo project is one of the projectes.
Source code in test/test_main.py
14 15 16 17 18 19 20 |
|
test_html_demo()
Fetch the welcome message for the demo project, look for key words
Source code in test/test_main.py
22 23 24 25 26 27 28 29 30 |
|
test_barriers_demo()
Test the barriers entry point
Source code in test/test_main.py
32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
test_mapinfo_demo()
Test the mapinfo entry point
Source code in test/test_main.py
46 47 48 49 50 51 52 53 54 55 |
|
test_targets_demo()
Test the targets entry point with the demo project
Source code in test/test_main.py
57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
test_unknown_project()
Each of the paths should check for an unknown project name
Source code in test/test_main.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
test_unknown_files()
Paths that fetch file should return 404 not found responses
Source code in test/test_main.py
94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
Tests for optipass,py
test_OP(barriers, targets, colnames)
Test the OP constructor. Make an instance, make sure all instance vars set to defaults.
Source code in test/test_optipass.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
test_OP_with_existing_data(barriers, targets, colnames)
Test the OP constructor when a path to existing data is passed
Source code in test/test_optipass.py
51 52 53 54 55 56 57 |
|
test_region_and_target_names(barriers, targets, colnames)
Verify region and target names
Source code in test/test_optipass.py
59 60 61 62 63 64 65 66 67 68 |
|
test_one_region_and_one_target(barriers, targets, colnames)
Check barrier frame when only one region and one target is used
Source code in test/test_optipass.py
70 71 72 73 74 75 76 77 78 79 |
|
test_one_target_input(barriers, targets, colnames)
Make an input file for single target.
Source code in test/test_optipass.py
81 82 83 84 85 86 87 88 89 90 91 92 |
|
test_two_target_input(barriers, targets, colnames)
Make an input file for two targets
Source code in test/test_optipass.py
94 95 96 97 98 99 100 101 102 103 104 105 |
|
test_unweighted(barriers, targets, colnames)
Make sure weights are initialized to 1s, one per target
Source code in test/test_optipass.py
107 108 109 110 111 112 |
|
test_weighted(barriers, targets, colnames)
Make sure weights are initialized with specified settings
Source code in test/test_optipass.py
114 115 116 117 118 119 |
|
test_paths(barriers, targets, colnames)
Verify the paths downstream from gates
Source code in test/test_optipass.py
121 122 123 124 125 126 127 128 129 130 131 |
|
test_output_parser_one_target(barriers, targets, colnames)
Parse an output file with only one target
Source code in test/test_optipass.py
133 134 135 136 137 138 139 140 141 142 143 |
|
test_output_parser_two_targets(barriers, targets, colnames)
Parse an output file with two targets
Source code in test/test_optipass.py
145 146 147 148 149 150 151 152 153 154 155 |
|
test_example_1(barriers, targets, colnames)
Collect all the results for Example 1 from the OptiPass User Manual.
Source code in test/test_optipass.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
test_example_4(barriers, targets, colnames)
Same as test_example_1, but using Example 4, which has two restoration targets.
Source code in test/test_optipass.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
test_potential_habitat_1(barriers, targets, colnames)
Test the method that computes potential habitat, using the results genearated for Example 1 in the OptiPass manual (Box 9).
Source code in test/test_optipass.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
test_potential_habitat_4(barriers, targets, colnames)
Same as test_potential_habitat_1, but using Example 4, with two restoration targets weighted differently (Box 11)
Source code in test/test_optipass.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|