Skip to content

Commit

Permalink
Merge branch 'master' into Fix-calcont#27-styling
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinab-choudhury authored Jun 16, 2024
2 parents 944fbd7 + 4da53f8 commit 8c2aac5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions mysite/tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,73 @@
from django.test import TestCase
from django.urls import reverse

ENGLISH_TO_OTHER_TEMPLATE = '../templates/Translator/EnglishToOther/'
HINDI_TO_OTHER_TEMPLATE = '../templates/Translator/HindiToOther/'
ENGLISH_TO_OTHER_TEMPLATE = "../templates/Translator/EnglishToOther/"
HINDI_TO_OTHER_TEMPLATE = "../templates/Translator/HindiToOther/"


class BaseTranslatorTestCase(TestCase):
def setUp(self):
self.dummy_request = {
'text': 'My name is Amar'
}
self.dummy_request = {"text": "My name is Amar"}


class EnglishToOtherTestCase(TestCase):
dummy_request = {
'text': 'my name is Amar'
}
dummy_request = {"text": "my name is Amar"}

def english_to_other(self, controller_name, expected_text):
response = self.client.post(reverse(controller_name), data=self.dummy_request)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, ENGLISH_TO_OTHER_TEMPLATE + controller_name + '_Transl.html')
decoded_html = html.unescape(response.content.decode('utf-8'))
self.assertTemplateUsed(
response, ENGLISH_TO_OTHER_TEMPLATE + controller_name + "_Transl.html"
)
decoded_html = html.unescape(response.content.decode("utf-8"))
self.assertIn(expected_text, decoded_html)

def test_english_to_hindi(self):
self.english_to_other('EnglishToHindi', 'मेरा नाम अमर है')
self.english_to_other("EnglishToHindi", "मेरा नाम अमर है")

def test_english_to_marathi(self):
self.english_to_other('EnglishToMarathi', 'माझे नाव अमर आहे')
self.english_to_other("EnglishToMarathi", "माझे नाव अमर आहे")

def test_english_to_german(self):
self.english_to_other('EnglishToGerman', 'mein Name ist Amar')
self.english_to_other("EnglishToGerman", "mein Name ist Amar")

def test_english_to_french(self):
self.english_to_other('EnglishToFrench', "je m'appelle Amar")
self.english_to_other("EnglishToFrench", "je m'appelle Amar")

#
def test_english_to_arabian(self):
self.english_to_other('EnglishToArabian', 'اسمي عمار')
self.english_to_other("EnglishToArabian", "اسمي عمار")

def test_english_to_spanish(self):
self.english_to_other('EnglishToSpanish', 'mi nombre es amar')
self.english_to_other("EnglishToSpanish", "mi nombre es amar")

def test_english_to_thai(self):
self.english_to_other('EnglishToThai', 'ฉันชื่ออามาร์')
self.english_to_other("EnglishToThai", "ฉันชื่ออามาร์")


class HindiToOtherTestCase(TestCase):
dummy_request = {
'text': 'यह एक परीक्षण संदेश है'
}
dummy_request = {"text": "यह एक परीक्षण संदेश है"}

def hindi_to_other(self, controller_name, expected_text):
response = self.client.post(reverse(controller_name), data=self.dummy_request)
self.assertEqual(response.status_code, 200)
decoded_json = json.loads(response.content)
self.assertEqual(expected_text, decoded_json['ConTex'])
self.assertEqual(expected_text, decoded_json["ConTex"])

def test_hindi_to_english(self):
self.hindi_to_other('HindiToEnglish', 'This is a test message')
self.hindi_to_other("HindiToEnglish", "this is a test message")

def test_hindi_to_marathi(self):
self.hindi_to_other('HindiToMarathi', 'हा एक चाचणी संदेश आहे')
self.hindi_to_other("HindiToMarathi", "हा एक चाचणी संदेश आहे")

def test_hindi_to_german(self):
self.hindi_to_other('HindiToGerman', 'Dies ist eine Testnachricht')
self.hindi_to_other("HindiToGerman", "Dies ist eine Testnachricht")

def test_hindi_to_french(self):
self.hindi_to_other('HindiToFrench', "Ceci est un message test")
self.hindi_to_other("HindiToFrench", "Ceci est un message test")

def test_hindi_to_spanish(self):
self.hindi_to_other('HindiToSpanish', 'Este es un mensaje de prueba')
self.hindi_to_other("HindiToSpanish", "Este es un mensaje de prueba")

def test_hindi_to_thai(self):
self.hindi_to_other('HindiToThai', 'นี่คือข้อความทดสอบ')
self.hindi_to_other("HindiToThai", "นี่คือข้อความทดสอบ")
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit 8c2aac5

Please sign in to comment.