Create and configure the argument parser.
()
| 136 | |
| 137 | |
| 138 | def create_argument_parser(): |
| 139 | """Create and configure the argument parser.""" |
| 140 | parser = argparse.ArgumentParser( |
| 141 | description="NLWeb Test Dispatcher - Run different types of tests", |
| 142 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 143 | epilog=""" |
| 144 | Test Types: |
| 145 | =========== |
| 146 | 1. end_to_end - Full query-to-results tests via NLWebHandler |
| 147 | 2. site_retrieval - Test get_sites functionality |
| 148 | 3. query_retrieval - Test retrieval.search without LLM |
| 149 | |
| 150 | File Formats: |
| 151 | ============= |
| 152 | Test files should be JSON arrays with objects containing: |
| 153 | - test_type: Type of test (end_to_end, site_retrieval, query_retrieval) |
| 154 | - Other fields specific to each test type |
| 155 | |
| 156 | Default Test Files: |
| 157 | ================== |
| 158 | - end_to_end_tests.json - End-to-end test cases |
| 159 | - site_retrieval_tests.json - Site retrieval test cases |
| 160 | - query_retrieval_tests.json - Query retrieval test cases |
| 161 | |
| 162 | Examples: |
| 163 | ========= |
| 164 | # Run all tests from a file |
| 165 | python run_tests.py --file all_tests.json |
| 166 | |
| 167 | # Run only end-to-end tests from a file |
| 168 | python run_tests.py --file end_to_end_tests.json --type end_to_end |
| 169 | |
| 170 | # Run a single end-to-end test |
| 171 | python run_tests.py --type end_to_end --query "pasta recipes" --site all |
| 172 | |
| 173 | # Run a single site retrieval test |
| 174 | python run_tests.py --type site_retrieval --db azure_ai_search |
| 175 | |
| 176 | # Run a single query retrieval test |
| 177 | python run_tests.py --type query_retrieval --query "chocolate cake" --db qdrant |
| 178 | |
| 179 | # Run all default test files |
| 180 | python run_tests.py --all |
| 181 | """) |
| 182 | |
| 183 | # Mode selection |
| 184 | mode_group = parser.add_mutually_exclusive_group(required=True) |
| 185 | |
| 186 | mode_group.add_argument( |
| 187 | '--file', '-f', |
| 188 | type=str, |
| 189 | help='JSON file containing test cases' |
| 190 | ) |
| 191 | |
| 192 | mode_group.add_argument( |
| 193 | '--all', |
| 194 | action='store_true', |
| 195 | help='Run all default test files' |