Skip to content

Commit

Permalink
add parameterized for different languages
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianWolfschmidtAA committed Apr 17, 2024
1 parent e86e505 commit f6ea313
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions tests/core/test_detect_language.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from intelligence_layer.core import (
DetectLanguage,
DetectLanguageInput,
Expand All @@ -6,17 +8,43 @@
)


def test_detect_language_returns_correct_language() -> None:
text = "Hello, my name is Niklas. I am working with Pit on this language detection piece."
@pytest.mark.parametrize(
"text_input,expected_language",
[
(
"Hello, my name is Niklas. I am working with Pit on this language detection piece.",
Language("en"),
),
(
"Hola, mi nombre es Niklas. Estoy trabajando con Pit en esta pieza de detección de idioma.",
Language("es"),
),
(
"Ciao, mi chiamo Niklas. Sto lavorando con Pit su questo pezzo di rilevamento della lingua.",
Language("it"),
),
(
"Hallo, mein Name ist Niklas. Ich arbeite mit Pit an diesem Stück zur Spracherkennung.",
Language("de"),
),
(
"Bonjour, je m'appelle Niklas. Je travaille avec Pit sur cette pièce de détection de langue.",
Language("fr"),
),
],
)
def test_detect_language_returns_correct_language(
text_input: str, expected_language: Language
) -> None:
task = DetectLanguage()
input = DetectLanguageInput(
text=text,
text=text_input,
possible_languages=[Language(lang) for lang in ["en", "de", "fr", "it", "es"]],
)
tracer = NoOpTracer()
output = task.run(input, tracer)

assert output.best_fit == Language("en")
assert output.best_fit == expected_language


def test_detect_language_returns_non_if_no_language_can_be_detected() -> None:
Expand Down

0 comments on commit f6ea313

Please sign in to comment.