1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/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()
|