Exemplo n.º 1
0
    def test_parse_mocked_celery(self, *args):
        with self.assertRaises(AuthorizationIsRequired):
            _parse("", "text", "pt_br", self.repository_version)
        with self.assertRaises(ValidationError):
            _parse(self.authorization, "", "pt_br", self.repository_version)
        with self.assertRaises(ValidationError):
            _parse(self.authorization, None, "pt_br", self.repository_version)
        with self.assertRaises(ValidationError):
            _parse(self.authorization, 23, "pt_br", self.repository_version)

        _parse(self.authorization, "text", "pt_br", self.repository_version)
Exemplo n.º 2
0
async def parsepost_handler(
        item: ParseRequest,
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
):

    return parse._parse(Authorization, item.text, item.language,
                        item.rasa_format)
Exemplo n.º 3
0
async def parse_handler(
    text: str,
    language: str = None,
    rasa_format: Optional[str] = False,
    request: Request = Depends(AuthorizationRequired()),
    Authorization: str = Header(..., description="Bearer your_key"),
):

    return parse._parse(Authorization, text, language, rasa_format)
Exemplo n.º 4
0
 def test_invalid_auth(self):
     with self.assertRaises(AuthorizationIsRequired):
         _parse("", "text", "pt_br", self.repository_version)
     with self.assertRaises(AuthorizationIsRequired):
         _parse(3, "text", "pt_br", self.repository_version)
     with self.assertRaises(AuthorizationIsRequired):
         _parse(None, "text", "pt_br", self.repository_version)
Exemplo n.º 5
0
 def test_invalid_text(self):
     with self.assertRaises(ValidationError):
         _parse(self.authorization, "", self.language,
                self.repository_version)
     with self.assertRaises(ValidationError):
         _parse(self.authorization, None, self.language,
                self.repository_version)
     with self.assertRaises(ValidationError):
         _parse(self.authorization, 3, self.language,
                self.repository_version)
Exemplo n.º 6
0
async def parsepost_handler(
        item: ParseRequest,
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
        user_agent: str = Header(None),
):

    return parse._parse(
        Authorization,
        item.text,
        item.language,
        item.rasa_format,
        item.repository_version,
        user_agent=user_agent,
        from_backend=item.from_backend,
    )
Exemplo n.º 7
0
async def parse_handler(
        text: str,
        language: str = None,
        rasa_format: Optional[str] = False,
        from_backend: Optional[bool] = Form(default=False),
        request: Request = Depends(AuthorizationRequired()),
        Authorization: str = Header(..., description="Bearer your_key"),
        user_agent: str = Header(None),
):

    return parse._parse(
        Authorization,
        text,
        language,
        rasa_format,
        user_agent=user_agent,
        from_backend=from_backend,
    )
Exemplo n.º 8
0
async def parse_handler(
        text: str = Form(...),
        language: str = Form(default=None),
        rasa_format: Optional[str] = Form(default=False),
        repository_version: Optional[int] = Form(default=None),
        from_backend: Optional[bool] = Form(default=False),
        request: Request = Depends(AuthorizationRequired()),  # flake8: noqa
        Authorization: str = Header(..., description="Bearer your_key"),
        user_agent: str = Header(None),
):

    return parse._parse(
        Authorization,
        text,
        language,
        rasa_format,
        repository_version,
        user_agent,
        from_backend,
    )
Exemplo n.º 9
0
 def test_invalid_language(self):
     with self.assertRaises(ValidationError):
         _parse(self.authorization, "text", "invalid_language",
                self.repository_version)
     with self.assertRaises(ValidationError):
         _parse(self.authorization, "text", 3, self.repository_version)
Exemplo n.º 10
0
 def test_parse_mocked_celery_timeout(self, *args):
     with self.assertRaises(CeleryTimeoutException):
         _parse(self.authorization, "text", "pt_br",
                self.repository_version)
Exemplo n.º 11
0
 def test_parse_invalid_language(self, *args):
     with self.assertRaises(ValidationError):
         _parse(self.authorization, "text", "pt_br",
                self.repository_version)