diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/xdg.py | 71 |
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')) |