mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
This changes the shebang at the top of the file to allow use Python from a virtual environment instead of hard-coding the path. This might not be strictly necessary, but reduces confusion and doesn't hurt.
43 lines
1.3 KiB
Python
Executable file
43 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env 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()
|