summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2024-06-28 16:42:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2024-06-28 16:42:56 (GMT)
commit21788df2799eb8976c1c68cd84abf0ffe92a7a45 (patch)
tree328acd460424011b3def91cd2d5425a5156caa53 /tests
parent00452431d4fb061f20a4eaa4c93b61014f7651ef (diff)
Handle the XDG directories.
Diffstat (limited to 'tests')
-rw-r--r--tests/common/xdg.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/common/xdg.py b/tests/common/xdg.py
new file mode 100644
index 0000000..df03c3c
--- /dev/null
+++ b/tests/common/xdg.py
@@ -0,0 +1,71 @@
+
+import os
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.common import get_xdg_cache_dir, get_xdg_config_dir, get_xdg_data_dir, \
+ get_xdg_state_dir, get_xdg_runtime_dir
+
+
+class TestXDG(ChrysalideTestCase):
+ """TestCase for XDG directories."""
+
+ def testXDGCachePath(self):
+ """Retrieve the XDG cache directory."""
+
+ filename = get_xdg_cache_dir('test.txt', False)
+
+ self.assertIsNotNone(filename)
+ self.assertTrue(filename.startswith(os.sep))
+ self.assertTrue(filename.endswith('test.txt'))
+
+ # Depends on current configuration
+ self.assertTrue('.cache' in filename)
+
+
+ def testXDGConfigPath(self):
+ """Retrieve the XDG config directory."""
+
+ filename = get_xdg_config_dir('test.txt', False)
+
+ self.assertIsNotNone(filename)
+ self.assertTrue(filename.startswith(os.sep))
+ self.assertTrue(filename.endswith('test.txt'))
+
+ # Depends on current configuration
+ self.assertTrue('.config' in filename)
+
+
+ def testXDGDataPath(self):
+ """Retrieve the XDG data directory."""
+
+ filename = get_xdg_data_dir('test.txt', False)
+
+ self.assertIsNotNone(filename)
+ self.assertTrue(filename.startswith(os.sep))
+ self.assertTrue(filename.endswith('test.txt'))
+
+ # Depends on current configuration
+ self.assertTrue(os.path.join('.local', 'share') in filename)
+
+
+ def testXDGStatePath(self):
+ """Retrieve the XDG state directory."""
+
+ filename = get_xdg_state_dir('test.txt', False)
+
+ self.assertIsNotNone(filename)
+ self.assertTrue(filename.startswith(os.sep))
+ self.assertTrue(filename.endswith('test.txt'))
+
+ # Depends on current configuration
+ self.assertTrue(os.path.join('.local', 'state') in filename)
+
+
+ def testXDGRuntimePath(self):
+ """Retrieve the XDG runtime directory."""
+
+ filename = get_xdg_runtime_dir('test.txt')
+
+ self.assertIsNotNone(filename)
+ self.assertTrue(filename.startswith(os.sep))
+ self.assertTrue(filename.endswith('test.txt'))