kuspia
commited on
Update test_google_trans.py
Browse files- tests/test_google_trans.py +14 -10
tests/test_google_trans.py
CHANGED
@@ -29,14 +29,7 @@ def test_abbreviations_and_languages_mapping():
|
|
29 |
g2 = GoogleTranslator(lang)
|
30 |
assert g1._source == g2._source
|
31 |
|
32 |
-
def
|
33 |
-
with pytest.raises(exceptions.LanguageNotSupportedException):
|
34 |
-
GoogleTranslator(source="", target="")
|
35 |
-
|
36 |
-
with pytest.raises(exceptions.LanguageNotSupportedException):
|
37 |
-
GoogleTranslator(source="auto", target="nothing")
|
38 |
-
|
39 |
-
# Case Senstivity checks
|
40 |
test_lang = 'Czech'
|
41 |
test_text = 'Hi, the sky is dark while the moon is white. Hurrah!! Denver is a city name in Colorado.'
|
42 |
translated_text = 'Ahoj, obloha je tmavá, zatímco měsíc je bílý. Hurá!! Denver je název města v Coloradu.'
|
@@ -54,16 +47,27 @@ def test_inputs():
|
|
54 |
temp += i
|
55 |
test_cases.append(temp)
|
56 |
random_cases = 5
|
57 |
-
random_test_cases = random.sample(test_cases, random_cases)
|
58 |
for case in random_test_cases:
|
59 |
assert GoogleTranslator(source='en', target=case).translate(test_text) == translated_text
|
60 |
|
61 |
-
|
62 |
assert GoogleTranslator(source='en', target='burMeSe').translate("Hello") == 'မင်္ဂလာပါ'
|
63 |
assert GoogleTranslator(source='en', target='Oriya').translate("What's up?") == 'କଣ ଚାଲିଛି?'
|
64 |
assert GoogleTranslator(source='en', target='kurManJi').translate("Nice is dice.") == 'Xweş xweş e.'
|
65 |
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def test_payload(google_translator):
|
68 |
|
69 |
with pytest.raises(exceptions.NotValidPayload):
|
|
|
29 |
g2 = GoogleTranslator(lang)
|
30 |
assert g1._source == g2._source
|
31 |
|
32 |
+
def case_sensitivity_checks():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
test_lang = 'Czech'
|
34 |
test_text = 'Hi, the sky is dark while the moon is white. Hurrah!! Denver is a city name in Colorado.'
|
35 |
translated_text = 'Ahoj, obloha je tmavá, zatímco měsíc je bílý. Hurá!! Denver je název města v Coloradu.'
|
|
|
47 |
temp += i
|
48 |
test_cases.append(temp)
|
49 |
random_cases = 5
|
50 |
+
random_test_cases = random.sample(test_cases, random_cases) # randomly choosing any five cases since list is in order of 2^n containing all cases
|
51 |
for case in random_test_cases:
|
52 |
assert GoogleTranslator(source='en', target=case).translate(test_text) == translated_text
|
53 |
|
54 |
+
def multiple_names_lang_checks():
|
55 |
assert GoogleTranslator(source='en', target='burMeSe').translate("Hello") == 'မင်္ဂလာပါ'
|
56 |
assert GoogleTranslator(source='en', target='Oriya').translate("What's up?") == 'କଣ ଚାଲିଛି?'
|
57 |
assert GoogleTranslator(source='en', target='kurManJi').translate("Nice is dice.") == 'Xweş xweş e.'
|
58 |
|
59 |
|
60 |
+
def test_inputs():
|
61 |
+
with pytest.raises(exceptions.LanguageNotSupportedException):
|
62 |
+
GoogleTranslator(source="", target="")
|
63 |
+
|
64 |
+
with pytest.raises(exceptions.LanguageNotSupportedException):
|
65 |
+
GoogleTranslator(source="auto", target="nothing")
|
66 |
+
|
67 |
+
case_sensitivity_checks()
|
68 |
+
multiple_names_lang_checks()
|
69 |
+
|
70 |
+
|
71 |
def test_payload(google_translator):
|
72 |
|
73 |
with pytest.raises(exceptions.NotValidPayload):
|