1
# -*- coding: utf-8 -*-
3
# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
5
# Copyright 2011 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
19
"""Platform independent tests for the XDG constants."""
23
from twisted.trial.unittest import TestCase
25
from ubuntuone.platform import xdg_base_directory
28
class TestBaseDirectory(TestCase):
29
"""Tests for the BaseDirectory module."""
31
def test_ubuntuone_log_dir(self):
32
"""The ubuntuone_log_dir is correct."""
33
expected = os.path.join(xdg_base_directory.xdg_cache_home,
35
self.assertEqual(expected, xdg_base_directory.ubuntuone_log_dir)
36
self.assertTrue(os.path.exists(expected))
38
def test_xdg_cache_home_is_bytes(self):
39
"""The returned path is bytes."""
40
actual = xdg_base_directory.xdg_cache_home
41
self.assertIsInstance(actual, str)
43
def test_xdg_data_home_is_bytes(self):
44
"""The returned path is bytes."""
45
actual = xdg_base_directory.xdg_data_home
46
self.assertIsInstance(actual, str)
48
def test_load_config_paths_filter(self):
49
"""Since those folders don't exist, this should be empty."""
50
self.assertEqual(list(xdg_base_directory.load_config_paths("x")), [])
52
def test_save_config_path(self):
53
"""The path should end with xdg_config/x (respecting the separator)."""
54
self.patch(os, "makedirs", lambda *args: None)
55
result = xdg_base_directory.save_config_path("x")
56
self.assertEqual(result.split(os.sep)[-2:], ['xdg_config', 'x'])