| Conditions | 7 | 
| Total Lines | 25 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | #!/usr/bin/python  | 
            ||
| 14 | def verify_status_code(request_response: requests.Response, file_name: str) -> tuple:  | 
            ||
| 15 | """Verify the status code of the post request to the search url and raise exceptions if the code is unexpected  | 
            ||
| 16 | |||
| 17 | :type request_response: requests.Response  | 
            ||
| 18 | :type file_name: str  | 
            ||
| 19 | :return:  | 
            ||
| 20 | """  | 
            ||
| 21 | if request_response.status_code == 200:  | 
            ||
| 22 | return STATUS_CODE_OK, ''  | 
            ||
| 23 | |||
| 24 | elif request_response.status_code == 429:  | 
            ||
| 25 | if 'limit of 150 searches' in request_response.text:  | 
            ||
| 26 |             raise DailyLimitReachedException('Daily search limit for unregistered users reached') | 
            ||
| 27 | elif 'limit of 300 searches' in request_response.text:  | 
            ||
| 28 |             raise DailyLimitReachedException('Daily search limit for basic users reached') | 
            ||
| 29 | else:  | 
            ||
| 30 |             raise DailyLimitReachedException('Daily search limit reached') | 
            ||
| 31 | elif request_response.status_code == 403:  | 
            ||
| 32 |         raise InvalidOrWrongApiKeyException("Invalid or wrong API key") | 
            ||
| 33 | elif request_response.status_code == 413:  | 
            ||
| 34 |         msg = "Payload too large, skipping file: {0:s}".format(file_name) | 
            ||
| 35 | return STATUS_CODE_SKIP, msg  | 
            ||
| 36 | else:  | 
            ||
| 37 |         msg = "Unknown status code: {0:d}".format(request_response.status_code) | 
            ||
| 38 | return STATUS_CODE_REPEAT, msg  | 
            ||
| 39 |