summaryrefslogtreecommitdiff
path: root/tests/common/xdg.py
blob: df03c3ce9e22d4d8c1e0fcc4424070260f6186e2 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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'))