1
1
import pytest
2
- from decouple import config
3
2
4
3
from daras_ai .image_input import gcs_blob_for
5
- from daras_ai_v2 import settings
6
4
from daras_ai_v2 .crypto import get_random_doc_id
7
5
from glossary_resources .models import GlossaryResource
8
- from tests .test_translation import google_translate_check
9
6
10
7
GLOSSARY = [
11
8
{
36
33
},
37
34
]
38
35
39
- TRANSLATION_TESTS_GLOSSARY = [
40
- (
41
- "एक एकड़ भूमि के लिए कितनी अग्निअस्त्र की आवश्यकता होती है" , # source
42
- "how many fire extinguishers are required for one acre of land" , # default translation
43
- "how many agniastra are required for one acre of land" , # using glossary
44
- ),
45
- (
46
- "गुई डॉट ए आई से हम क्या कर सकते हैं" ,
47
- "What can we do with Gui.AI" ,
48
- "What can we do with Gooey.AI" ,
49
- ),
50
- (
51
- "गुई ए आई से हम क्या कर सकते हैं" ,
52
- "What can we do with AI" ,
53
- "What can we do with Gooey.AI" ,
54
- ),
55
- (
56
- "मेरे मिर्ची पर लाल धब्बे आ गये हैं" ,
57
- "My chillies have got red spots" ,
58
- "My Jalapeño have got red spots" ,
59
- ),
60
- ]
61
-
62
36
63
37
@pytest .fixture
64
38
def glossary_url ():
@@ -73,22 +47,3 @@ def glossary_url():
73
47
finally :
74
48
blob .delete ()
75
49
GlossaryResource .objects .all ().delete ()
76
-
77
-
78
- @pytest .mark .skipif (
79
- not settings .GS_BUCKET_NAME or not config ("RUN_GOOGLE_TRANSLATE_TESTS" , None ),
80
- reason = "No bucket name or run google translate tests" ,
81
- )
82
- def test_google_translate_glossary (transactional_db , glossary_url , threadpool_subtest ):
83
- for text , expected , expected_with_glossary in TRANSLATION_TESTS_GLOSSARY :
84
- threadpool_subtest (
85
- google_translate_check ,
86
- text ,
87
- expected ,
88
- )
89
- threadpool_subtest (
90
- google_translate_check ,
91
- text ,
92
- expected_with_glossary ,
93
- glossary_url = glossary_url ,
94
- )
0 commit comments