41
38
class GSettingsAccessTests(TestCase):
43
def test_incorrect_schema_doesnt_raise_exception(self):
45
lambda: ap_fixtures.get_gsettings_value('foo', 'bar'),
40
def test_incorrect_schema_raises_exception(self):
42
lambda: ap_fixtures._gsetting_get_setting('com.foo.', 'baz'),
46
def test_incorrect_key_raises_exception(self):
48
lambda: ap_fixtures._gsetting_get_setting(
49
'org.gnome.system.locale',
49
55
def test_get_value_returns_expected_value(self):
50
with patch.object(ap_fixtures.subprocess, 'check_output') as check_out:
51
check_out.return_value = 'buzz'
53
ap_fixtures.get_gsettings_value('foo', 'bar'),
57
def test_get_value_strips_newline(self):
58
with patch.object(ap_fixtures.subprocess, 'check_output') as check_out:
59
check_out.return_value = 'buzz\n'
61
ap_fixtures.get_gsettings_value('foo', 'bar'),
56
with patch.object(ap_fixtures, '_gsetting_get_setting') as get_setting:
58
setting.get_boolean.return_value = True
59
get_setting.return_value = setting
61
ap_fixtures.get_bool_gsettings_value('foo', 'bar'),
66
66
class OSKAlwaysEnabledTests(TestCase):
68
def test_sets_stayhidden_to_false(self):
69
with patch.object(ap_fixtures, 'set_gsettings_value') as set_gsetting:
68
@patch.object(ap_fixtures, '_gsetting_get_setting')
69
def test_sets_stayhidden_to_False(self, gs):
70
with patch.object(ap_fixtures, 'set_bool_gsettings_value') as set_gs:
70
71
with ap_fixtures.OSKAlwaysEnabled():
71
set_gsetting.assert_called_once_with(
72
set_gs.assert_called_once_with(
72
73
'com.canonical.keyboard.maliit',
77
78
def test_resets_value_to_original(self):
78
with patch.object(ap_fixtures, 'set_gsettings_value') as set_gset:
79
with patch.object(ap_fixtures, 'get_gsettings_value') as get_gset:
80
get_gset.return_value = 'foo'
79
with patch.object(ap_fixtures, 'set_bool_gsettings_value') as set_gs:
80
with patch.object(ap_fixtures, 'get_bool_gsettings_value') as get_gs: # NOQA
81
get_gs.return_value = 'foo'
81
82
with ap_fixtures.OSKAlwaysEnabled():
83
set_gset.assert_called_with(
84
set_gs.assert_called_with(
84
85
'com.canonical.keyboard.maliit',