Beispiel #1
0
async def train_handler(
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
):
    result = train.train_handler(Authorization)
    if result.get("status") and result.get("error"):
        raise HTTPException(status_code=400, detail=result)
    return result
Beispiel #2
0
async def train_handler(
        request: Request = Depends(AuthorizationRequired()),
        repository_version: Optional[int] = Form(default=None),
        language: Optional[str] = Form(default=None),
        Authorization: str = Header(..., description="Bearer your_key"),
):
    result = train.train_handler(Authorization, repository_version, language)
    if result.get("status") and result.get("error"):
        raise HTTPException(status_code=400, detail=result)
    return result
Beispiel #3
0
 def test_specific_language(self, *args):
     r = train_handler(self.authorization, self.repository_version, "pt_br")
     expected = {
         "SUPPORTED_LANGUAGES": ["pt_br", "en"],
         "languages_report": {
             "pt_br": {
                 "status": "processing"
             }
         },
     }
     self.assertEqual(r, expected)
Beispiel #4
0
 def test_invalid_auth(self):
     with self.assertRaises(AuthorizationIsRequired):
         train_handler("", self.repository_version, "pt_br")
     with self.assertRaises(AuthorizationIsRequired):
         train_handler(None, self.repository_version, "pt_br")
     with self.assertRaises(AuthorizationIsRequired):
         train_handler(3, self.repository_version, "pt_br")
Beispiel #5
0
 def test_invalid_language(self):
     with self.assertRaises(ValidationError):
         train_handler(self.authorization, self.repository_version,
                       "invalid_language")
     with self.assertRaises(ValidationError):
         train_handler(self.authorization, self.repository_version, 3)