Skip to content

Commit

Permalink
Add test for custom document properties
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarsay committed Dec 6, 2021
1 parent f7497e0 commit 37ccf4d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ base_lo_dir = get_option('libreoffice-dir')

gettext_package = 'parlatype'


python_utils_dir = join_paths(meson.current_source_dir(), 'extension', 'python', 'components', 'pythonpath')
python_dir = join_paths(meson.current_source_dir(), 'extension', 'python', 'components')
python_utils_dir = join_paths(python_dir, 'pythonpath')

if bundled
subdir('appdata')
Expand Down
2 changes: 2 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
python = find_program('python3')

testpaths = [
python_dir, # files to be tested
python_utils_dir, # files to be tested
meson.current_source_dir(), # tests (unittest can't import paths)
]
Expand All @@ -10,6 +11,7 @@ test_env.prepend('PYTHONPATH', testpaths)

unit_tests = [
'test_parlatype_utils',
'test_document_link',
]

foreach test_name: unit_tests
Expand Down
50 changes: 50 additions & 0 deletions tests/test_document_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
'''
Copyright (C) Gabor Karsay 2021 <gabor.karsay@gmx.at>
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.
'''

import unittest
import uno
from unotest import UnoRemoteConnection

from Parlatype import get_link_url


class TestUtils(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._uno = UnoRemoteConnection({'program': 'soffice',
'verbose': False})
cls._uno.setUp()
cls.document = cls._uno.openEmptyWriterDoc()

@classmethod
def tearDownClass(cls):
cls._uno.tearDown()

def test_document_link(self):
"""
Get, set and remove custom property "Parlatype"
"""

doc = self.__class__._uno.getDoc()

# Initially empty document has no custom property
self.assertIsNone(get_link_url(doc))


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_parlatype_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TestUtils(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._uno = UnoRemoteConnection({'program': 'soffice',
'verbose': False})
'verbose': True})
cls._uno.setUp()
cls.document = cls._uno.openEmptyWriterDoc()

Expand Down

0 comments on commit 37ccf4d

Please sign in to comment.