-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_ghostkey.py
More file actions
executable file
·46 lines (39 loc) · 1.71 KB
/
Copy pathtest_ghostkey.py
File metadata and controls
executable file
·46 lines (39 loc) · 1.71 KB
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
44
45
46
#!/usr/bin/env python3
import unittest
import json
from pathlib import Path
import time
from ghostkey.settings import Settings
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class TestGhostKey(unittest.TestCase):
def setUp(self):
self.settings = Settings()
def test_default_settings(self):
"""Test that default settings are loaded correctly"""
self.assertEqual(self.settings.get("hotkeys", "type_text"), "<ctrl>+<alt>+v")
self.assertEqual(self.settings.get("appearance", "window_width"), 400)
self.assertEqual(self.settings.get("appearance", "window_height"), 300)
self.assertTrue(self.settings.get("appearance", "dark_theme"))
def test_save_settings(self):
"""Test that settings can be saved and loaded"""
test_width = 500
self.settings.set("appearance", "window_width", test_width)
# Create new Settings instance to load from file
new_settings = Settings()
self.assertEqual(new_settings.get("appearance", "window_width"), test_width)
def test_config_file_creation(self):
"""Test that config file is created in the correct location"""
config_path = Path(self.settings.config_file)
self.assertTrue(config_path.exists())
self.assertTrue(config_path.is_file())
# Test file contains valid JSON
with open(config_path, 'r') as f:
config_data = json.load(f)
self.assertIsInstance(config_data, dict)
self.assertIn("hotkeys", config_data)
self.assertIn("appearance", config_data)
self.assertIn("behavior", config_data)
if __name__ == '__main__':
unittest.main()