commit 5625a4bfbeefd513aac0029f0493f0644cbc9778 Author: vaydheesh Date: Wed Jul 31 22:08:17 2019 +0530 added: tests for apertium/installer.py diff --git a/tests/__init__.py b/tests/__init__.py index 2d5810f..469a698 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,7 @@ +import importlib.util import os +import platform +import shutil import sys import unittest @@ -69,6 +72,33 @@ class TestGenerate(unittest.TestCase): apertium.generate('spa', 'cat') +class TestInstallation(unittest.TestCase): + def test_apertium_base(self): + apertium.installer.install_apertium() + apertium_exists = False + if shutil.which('lt-proc'): + apertium_exists = True + self.assertTrue(apertium_exists, 'apertium binaries not find') + + def test_install_module(self): + apertium.installer.install_module('kir') + importlib.reload(apertium) + try: + apertium.analyze('kir', 'cats') + except apertium.ModeNotInstalled: + self.fail('apetium.install_module not working') + + def test_install_wrapper(self): + apertium.installer.install_wrapper('python3-lttoolbox') + if platform.system() == 'Linux': + sys.path.append('/usr/lib/python3/dist-packages') + spec = importlib.util.find_spec('lttoolbox') + apertium_exists = False + if spec: + apertium_exists = True + self.assertTrue(apertium_exists, 'Wrapper not installed') + + class TestTranslate(unittest.TestCase): def test_translator_en_spa(self): translator = apertium.Translator('eng', 'spa')