~ubuntu-branches/ubuntu/precise/ubuntuone-client/precise-201112142106

« back to all changes in this revision

Viewing changes to tests/platform/test_xdg_base_directory.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-08-09 12:47:56 UTC
  • mfrom: (1.1.53 upstream)
  • Revision ID: james.westby@ubuntu.com-20110809124756-7nzilp3oix0a1yl9
Tags: 1.7.1-0ubuntu1
* New upstream release.
* debian/*:
  - Removed obsolete pycompat file
  - Removed ubuntuone-client-gnome deps and binary packaging, as it was
    moved out to separate project upstream.
  - Updated copyright to remove obsolete file reference
* debian/patches:
  - Removed patches which have been included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
 
 
19
"""Platform independent tests for the XDG constants."""
 
20
 
 
21
import os
 
22
 
 
23
from twisted.trial.unittest import TestCase
 
24
 
 
25
from ubuntuone.platform import xdg_base_directory
 
26
 
 
27
 
 
28
class TestBaseDirectory(TestCase):
 
29
    """Tests for the BaseDirectory module."""
 
30
 
 
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,
 
34
                                'ubuntuone', 'log')
 
35
        self.assertEqual(expected, xdg_base_directory.ubuntuone_log_dir)
 
36
        self.assertTrue(os.path.exists(expected))
 
37
 
 
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)
 
42
 
 
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)
 
47
 
 
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")), [])
 
51
 
 
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'])