mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 17:05:34 +00:00
This change rename the test files for Linux according to the discussion at the Keyman conference in November 2024. Python is pretty opinionated about the naming of files, so we have to use `*_tests.py` as test filename instead of the usual `*.tests.py`.
43 lines
1.3 KiB
Python
Executable file
43 lines
1.3 KiB
Python
Executable file
#!/usr/bin/python3
|
|
import unittest
|
|
from gi.repository import Gio
|
|
|
|
from keyman_config.dconf_util import get_option, set_option, GSETTINGS_BASE
|
|
|
|
|
|
class TestKeymanOptions(unittest.TestCase):
|
|
def setUp(self):
|
|
self.settings = Gio.Settings.new(GSETTINGS_BASE)
|
|
|
|
def tearDown(self):
|
|
# Reset the GSettings to its original state
|
|
self.settings.reset("options")
|
|
|
|
def test_get_option_no_info(self):
|
|
# Test getting options with invalid info
|
|
options = get_option({})
|
|
self.assertEqual(options, {})
|
|
|
|
def test_get_option_invalid_info(self):
|
|
# Test getting options with invalid info
|
|
info = {"packageID": "", "keyboardID": ""}
|
|
options = get_option(info)
|
|
self.assertEqual(options, {})
|
|
|
|
def test_get_option_valid_info(self):
|
|
# Test getting options with valid info
|
|
info = {"packageID": "foo", "keyboardID": "bar"}
|
|
options = get_option(info)
|
|
self.assertIsInstance(options, dict)
|
|
|
|
def test_set_option(self):
|
|
# Test setting options
|
|
info = {"packageID": "foo", "keyboardID": "bar"}
|
|
options = {"set_nfc": "1"}
|
|
set_option(info, options)
|
|
retrieved_options = get_option(info)
|
|
self.assertEqual(retrieved_options, options)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|