Example #1
0
async def debug_parsepost_handler(
        item: DebugParseRequest,
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
):

    return debug_parse._debug_parse(Authorization, item.text, item.language,
                                    item.repository_version)
Example #2
0
async def debug_parse_handler(
        text: str = Form(...),
        language: str = Form(...),
        repository_version: Optional[int] = Form(default=None),
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
):

    return debug_parse._debug_parse(Authorization, text, language,
                                    repository_version)
 def test_invalid_authorization(self):
     with self.assertRaises(AuthorizationIsRequired):
         _debug_parse("", self.text, self.language)
     with self.assertRaises(AuthorizationIsRequired):
         _debug_parse(None, self.text, self.language)
     with self.assertRaises(AuthorizationIsRequired):
         _debug_parse(2, self.text, self.language)
 def test_invalid_text(self):
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, "", self.language)
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, None, self.language)
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, 2, self.language)
 def test_invalid_language(self):
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, self.text, "invalid_language")
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, self.text, None)
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, self.text, "")
 def test_celery_timeout(self, *args):
     with self.assertRaises(CeleryTimeoutException):
         _debug_parse(self.authorization, self.text, self.language)
 def test_no_version(self, *args):
     with self.assertRaises(ValidationError):
         _debug_parse(self.authorization, self.text, self.language)
 def test_default(self, *args):
     _debug_parse(self.authorization, self.text, self.language)