148 lines
3.5 KiB
Python
148 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
# coding: utf-8
|
|
|
|
import unittest
|
|
from tempfile import NamedTemporaryFile
|
|
import easymacro as app
|
|
from test_config import *
|
|
|
|
|
|
LIBO_NAME = 'LibreOffice'
|
|
# ~ @unittest.SkipTest
|
|
|
|
|
|
class BaseTest(unittest.TestCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
pass
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
pass
|
|
|
|
def setUp(self):
|
|
msg = f'In method: {self._testMethodName}'
|
|
app.debug(msg)
|
|
|
|
def tearDown(self):
|
|
pass
|
|
|
|
|
|
# ~ class TestDocuments(BaseTest):
|
|
|
|
# ~ def test_new_doc(self):
|
|
# ~ result = app.new_doc()
|
|
# ~ self.assertIsInstance(result, app.LOCalc)
|
|
# ~ result.close()
|
|
|
|
# ~ def test_get_type_doc(self):
|
|
# ~ expected = 'calc'
|
|
# ~ result = app.new_doc()
|
|
# ~ self.assertEqual(result.type, expected)
|
|
# ~ result.close()
|
|
|
|
|
|
class TestVars(BaseTest):
|
|
|
|
def test_01_os(self):
|
|
expected = OS
|
|
result = app.OS
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_02_desktop(self):
|
|
expected = DESKTOP
|
|
result = app.DESKTOP
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_03_pc(self):
|
|
expected = PC
|
|
result = app.PC
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_04_user(self):
|
|
expected = USER
|
|
result = app.USER
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_05_is_win(self):
|
|
expected = IS_WIN
|
|
result = app.IS_WIN
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_06_is_mac(self):
|
|
expected = IS_MAC
|
|
result = app.IS_MAC
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_07_name(self):
|
|
expected = LIBO_NAME
|
|
result = app.NAME
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_08_version(self):
|
|
expected = LIBO_VERSION
|
|
result = app.VERSION
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_09_language(self):
|
|
expected = LANGUAGE
|
|
result = app.LANGUAGE
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_10_lang(self):
|
|
expected = LANG
|
|
result = app.LANG
|
|
self.assertEqual(result, expected)
|
|
|
|
def test_11_info_debug(self):
|
|
expected = str
|
|
result = app.INFO_DEBUG
|
|
self.assertIsInstance(result, expected)
|
|
|
|
|
|
class TestTools(BaseTest):
|
|
|
|
def test_01_debug_one_message(self):
|
|
result = app.debug('Work fine')
|
|
self.assertIsNone(result)
|
|
|
|
def test_02_debug_some_messages(self):
|
|
result = app.debug('One', 'Two', 'Three')
|
|
self.assertIsNone(result)
|
|
|
|
def test_03_error_message(self):
|
|
result = app.error('Not working...')
|
|
self.assertIsNone(result)
|
|
|
|
def test_04_info_one_message(self):
|
|
result = app.info('PyUno')
|
|
self.assertIsNone(result)
|
|
|
|
def test_05_info_some_message(self):
|
|
result = app.info('Calc', 'Writer', 'Calc')
|
|
self.assertIsNone(result)
|
|
|
|
def test_06_save_log(self):
|
|
data = 'Test Data'
|
|
with NamedTemporaryFile() as f:
|
|
result = app.save_log(f.name, data)
|
|
self.assertTrue(result)
|
|
|
|
def test_07_create_instance_not_exists(self):
|
|
result = app.create_instance('no.exists.zaz')
|
|
self.assertIsNone(result)
|
|
|
|
def test_08_create_instance(self):
|
|
result = app.create_instance('com.sun.star.util.PathSettings')
|
|
self.assertIsNotNone(result)
|
|
|
|
def test_09_get_app_config(self):
|
|
expected = LIBO_NAME
|
|
result = app.get_app_config('org.openoffice.Setup/Product', 'ooName')
|
|
self.assertEqual(result, expected)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main(exit=False)
|