64 | | === Create a Generic Test Function for Search Tests === |
65 | | Currently the Sahana test framework has a {{{create}}} function in {{{eden/modules/tests/web2unittests.py}}} which makes it simple to write tests for creating records. A similar function could be written for the Search Function: This would do the following: |
66 | | * Have parameters for: |
67 | | * The search query -- which fields to search on and their values. |
68 | | * Look at the {{{create}}} function's {{{data}}} parameter. It has additional information about the form. Do you need anything like that? Could you use the same format for your parameter? |
69 | | * Would it make sense to share any code with {{{create}}}? |
70 | | * The expected results. It is sufficient to just test that the right number of records are returned and give a list of the first n (determined in test case) values in a specific sorted column. |
71 | | * You may want tests that return no results, or one result, or multiple results. What would be a good way to pass in the expected results? |
72 | | * Fill the search criteria in the advanced search form. |
73 | | * Execute the search. |
74 | | * Check that the results are exactly as given. |
75 | | * If feasible, extend this to also test simple search. |
76 | | * Can you use the same data to test the simple search form? |
77 | | * Does the caller need to tell you which field the simple search uses? |
78 | | * Think about what code could be shared between your {{{search}}} function, the {{{create}}} function, and the {{{report}}} function task below. |
79 | | Test this function in at least one test script. |
| 64 | === ~~Create a Generic Test Function for Search Tests~~ === |
| 65 | ~~Currently the Sahana test framework has a {{{create}}} function in {{{eden/modules/tests/web2unittests.py}}} which makes it simple to write tests for creating records. A similar function could be written for the Search Function: This would do the following:~~ |
| 66 | * ~~Have parameters for:~~ |
| 67 | * ~~The search query -- which fields to search on and their values.~~ |
| 68 | * ~~Look at the {{{create}}} function's {{{data}}} parameter. It has additional information about the form. Do you need anything like that? Could you use the same format for your parameter?~~ |
| 69 | * ~~Would it make sense to share any code with {{{create}}}?~~ |
| 70 | * ~~The expected results. It is sufficient to just test that the right number of records are returned and give a list of the first n (determined in test case) values in a specific sorted column.~~ |
| 71 | * ~~You may want tests that return no results, or one result, or multiple results. What would be a good way to pass in the expected results?~~ |
| 72 | * ~~Fill the search criteria in the advanced search form.~~ |
| 73 | * ~~Execute the search.~~ |
| 74 | * ~~Check that the results are exactly as given.~~ |
| 75 | * ~~If feasible, extend this to also test simple search.~~ |
| 76 | * ~~Can you use the same data to test the simple search form?~~ |
| 77 | * ~~Does the caller need to tell you which field the simple search uses?~~ |
| 78 | * ~~Think about what code could be shared between your {{{search}}} function, the {{{create}}} function, and the {{{report}}} function task below.~~ |
| 79 | ~~Test this function in at least one test script.~~ |