| 112 | |
| 113 | == Useful Information about the test suite == |
| 114 | |
| 115 | === Tests for each template === |
| 116 | |
| 117 | * The tests to be run on a template are explicitly defined in {{{private/templates/<template_name>/tests.py}}} file. |
| 118 | * The list {{{current.selenium_tests}}} in the above file contains the class names of all the tests which are to be run for the template. |
| 119 | |
| 120 | === Functions === |
| 121 | The test suite provides the following functions - |
| 122 | |
| 123 | ==== login ==== |
| 124 | * Usage - {{{login(account, nexturl)}}} |
| 125 | * {{{account}}} is the user with whom we wish to login. Typically, "admin". |
| 126 | * {{{nexturl}}} is the url to be visited after logging in the user. |
| 127 | |
| 128 | ==== create ==== |
| 129 | |
| 130 | Used to create records in the database. |
| 131 | |
| 132 | * Usage - {{{create(table_name, data)}}} |
| 133 | * {{{table_name}}} is the name of the table in which we wish to insert records |
| 134 | * {{{data}}} is a list of tuples, where each tuple represents information about one field in the table. |
| 135 | * Eg - [ ( column_name1, data1, ... ), ( column_name2, data2, ... ), .. so on ] |
| 136 | * The test suite automatically determines the following field types from the HTML class names in the create form - |
| 137 | * option(dropdown) |
| 138 | * autocomplete |
| 139 | * date |
| 140 | * datetime |
| 141 | * normal text input |
| 142 | * Hence, for the above field types, just 2 arguments need to be provided in the tuple - column name and data to be inserted. |
| 143 | * Eg - {{{ (organisation_id, "International Federation of Red Cross and Red Crescent Societies") }}} |
| 144 | * For other field types listed below, an appropriate third argument needs to be provided. |
| 145 | * checkbox |
| 146 | * Embedded form fields - |
| 147 | * Eg - "pr_person" embedded in "hrm_human_resource" |
| 148 | * Specific widgets - |
| 149 | * inv_widget |
| 150 | * supply_widget |
| 151 | * facility_widget |
| 152 | * gis_location |
| 153 | |
| 154 | * Selection of the option from the dropdown field - |
| 155 | * Longest Word Trimmed Search is used - Amongst the options in the dropdown field, the option which has most number of word matches with the input string(in the test data) is selected. |
| 156 | * Note : In case of filling in an organisation name, the data should not contain both name and acronym. |
| 157 | * Eg - correct usage : {{{ (organisation_id, "International Federation of Red Cross and Red Crescent Societies") }}} |
| 158 | * Incorrect usage : {{{ (organisation_id, "International Federation of Red Cross and Red Crescent Societies (IFRC)") }}} |
| 159 | |
| 160 | ==== Search ==== |
| 161 | |
| 162 | * Usage - {{{ search(form_type, results_expected, fields, row_count, **kwargs) }}} |
| 163 | * form_type: This can either be search.simple_form or search.advanced_form |
| 164 | * results_expected: Are results expected? : True/False |
| 165 | * fields : a tuple of dictionaries, each dictionary specifying a field which is to be checked/unchecked in the form. |
| 166 | * row_count : Expected row count |
| 167 | * {{{ {"tablename":tablename, "key":key, "filters":[(field,value),...]} }}} can be passed to get the resource and eventually the DB row count. |
| 168 | |
| 169 | ==== report ==== |
| 170 | |
| 171 | * Usage - {{{ report(fields, report_of, grouped_by, report_fact, *args, **kwargs) }}} |
| 172 | * fields : a tuple of dictionaries, each dictionary specifying a field which is to be checked/unchecked in the form. |
| 173 | * report_of : The field whose report is to be formed. The option in 'Report of' |
| 174 | * grouped_by : The field for which the report is to be grouped by. The option in 'Grouped by' |
| 175 | * report_fact : The option in 'Value' |
| 176 | |