-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: python | ||
|
||
python: | ||
- "3.6" | ||
|
||
install: | ||
- pip3 install pytest==5.4.3 timeout-decorator==0.4.1 | ||
|
||
script: | ||
- python3 -m pytest --cache-clear --tb=long --showlocals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
|
||
import dhwani | ||
|
||
_test_id_match = { | ||
"00": "Sanity test for the returned supported language dictionary", | ||
"01": "Converter class API testing", | ||
} | ||
|
||
|
||
class Test_Dhwani_API(unittest.TestCase): | ||
def setUp(self): | ||
"""Load the supported conversions | ||
""" | ||
self.supported_conversions_dict = dhwani.get_supported_conversions() | ||
|
||
def test_id_00(self): | ||
"""Sanity test for the returned supported language dictionary | ||
""" | ||
self.assertIsNotNone( | ||
self.supported_conversions_dict, | ||
msg="{} returned None".format("dhwani.get_lang_mappings()"), | ||
) | ||
|
||
self.assertTrue( | ||
len(self.supported_conversions_dict) > 0, | ||
msg="No supported convertions available.", | ||
) | ||
|
||
for src_lang_code in self.supported_conversions_dict: | ||
self.assertIsInstance(self.supported_conversions_dict[src_lang_code], list) | ||
self.assertTrue( | ||
len(self.supported_conversions_dict[src_lang_code]) > 0, | ||
msg="src {} does not support convertions to any destination language".format( | ||
src_lang_code | ||
), | ||
) | ||
|
||
def test_id_01(self): | ||
"""Converter class API testing | ||
""" | ||
|
||
for src_lang_code in self.supported_conversions_dict: | ||
for dest_lang_code in self.supported_conversions_dict[src_lang_code]: | ||
converter = dhwani.Converter(src_lang_code, dest_lang_code) | ||
|
||
self.assertIsInstance(converter, dhwani.Converter) # Needed? | ||
self.assertIsNotNone(converter.convert) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
import unittest.mock | ||
import timeout_decorator | ||
|
||
import dhwani | ||
import dhwani.mappings.utils as utils | ||
|
||
_test_id_match = { | ||
"00": "Test that the mappings do not form any loops", | ||
} | ||
|
||
|
||
class Test_Dhwani_API(unittest.TestCase): | ||
def setUp(self): | ||
"""Load the supported conversions | ||
""" | ||
self.supported_conversions_dict = dhwani.get_supported_conversions() | ||
|
||
def load_src_string_from_codes(self, src_lang_code: str, dest_lang_code: str): | ||
mappings_list = utils.get_lang_mappings(src_lang_code, dest_lang_code) | ||
toret_list = [list(element.keys())[0] for element in mappings_list] | ||
toret = "".join(toret_list) | ||
return toret | ||
|
||
@timeout_decorator.timeout(2) # Assumption that it wont take more than this. | ||
def _convert(self, converter, *args, **kwargs): | ||
return converter.convert(*args, **kwargs) | ||
|
||
def test_id_00(self): | ||
"""Test that the mappings do not form any loops | ||
""" | ||
|
||
for src_lang_code in self.supported_conversions_dict: | ||
for dest_lang_code in self.supported_conversions_dict[src_lang_code]: | ||
src_text = self.load_src_string_from_codes( | ||
src_lang_code, dest_lang_code | ||
) | ||
|
||
converter = dhwani.Converter(src_lang_code, dest_lang_code) | ||
self.assertIsNotNone(converter.convert) | ||
|
||
dest_text = self._convert(converter, src_text) |