Beispiel #1
0
 def test_invalid_percentage_replace(self):
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, 4, "a")
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, 4, None)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, 4, -2.0)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, 4, 0)
Beispiel #2
0
 def test_invalid_n_sentences(self):
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, "1", 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, None, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, -3, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, self.language, 11111111, 0.6)
Beispiel #3
0
async def sentence_suggestion_post_handler(item: SentenceSuggestionRequest, ):

    return sentence_suggestion._sentence_suggestion(
        item.text,
        item.language,
        item.n_sentences_to_generate,
        item.percentage_to_replace,
    )
Beispiel #4
0
async def sentence_suggestion_handler(
        text: str = Form(...),
        language: str = Form(...),
        n_sentences_to_generate: int = Form(default=10),
        percentage_to_replace: float = Form(default=0.3),
):

    return sentence_suggestion._sentence_suggestion(text, language,
                                                    n_sentences_to_generate,
                                                    percentage_to_replace)
Beispiel #5
0
 def test_invalid_text(self):
     with self.assertRaises(ValidationError):
         _sentence_suggestion("", self.language, 5, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(3, self.language, 5, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(None, self.language, 5, 0.6)
Beispiel #6
0
 def test_invalid_language(self):
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, "invalid_language", 5, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, "", 5, 0.6)
     with self.assertRaises(ValidationError):
         _sentence_suggestion(self.text, None, 5, 0.6)
Beispiel #7
0
 def test_default(self, *args):
     _sentence_suggestion(self.text, self.language, 5, 0.6)
Beispiel #8
0
 def test_celery_timeout(self, *args):
     with self.assertRaises(CeleryTimeoutException):
         _sentence_suggestion(self.text, self.language, 5, 0.6)