If the API model is working, return True, else return False. Returns: bool: If the API model is working, return True, else return False.
(self)
| 57 | return ret_code, answer, log |
| 58 | |
| 59 | def working(self): |
| 60 | """If the API model is working, return True, else return False. |
| 61 | |
| 62 | Returns: |
| 63 | bool: If the API model is working, return True, else return False. |
| 64 | """ |
| 65 | self.old_timeout = None |
| 66 | if hasattr(self, 'timeout'): |
| 67 | self.old_timeout = self.timeout |
| 68 | self.timeout = 120 |
| 69 | |
| 70 | retry = 5 |
| 71 | while retry > 0: |
| 72 | ret = self.generate('hello') |
| 73 | if ret is not None and ret != '' and self.fail_msg not in ret: |
| 74 | if self.old_timeout is not None: |
| 75 | self.timeout = self.old_timeout |
| 76 | return True |
| 77 | retry -= 1 |
| 78 | |
| 79 | if self.old_timeout is not None: |
| 80 | self.timeout = self.old_timeout |
| 81 | return False |
| 82 | |
| 83 | def check_content(self, msgs): |
| 84 | """Check the content type of the input. Four types are allowed: str, dict, liststr, listdict. |
no test coverage detected