~ralsina/ubuntuone-control-panel/fix-scroll

« back to all changes in this revision

Viewing changes to ubuntuone/control_panel/tests/test_utils.py

  • Committer: natalia.bidart at canonical
  • Date: 2010-09-15 21:43:48 UTC
  • Revision ID: natalia.bidart@canonical.com-20100915214348-qd7vpoj85z0jhx0m
Initial directory structure for new project.

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 2010 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
"""The test suite for the control panel utilities."""
 
20
 
 
21
import os
 
22
 
 
23
from twisted.trial.unittest import TestCase
 
24
 
 
25
from ubuntuone.control_panel import utils
 
26
 
 
27
 
 
28
class GetDataTestCase(TestCase):
 
29
    """Test case for get_data_dir and get_data_file."""
 
30
 
 
31
    def test_get_data_dir_relative(self):
 
32
        """The relative path for the data directory is correctly retrieved."""
 
33
        module = os.path.dirname(utils.__file__)
 
34
        expected = os.path.abspath(os.path.join(module, os.path.pardir,
 
35
                                                os.path.pardir, 'data'))
 
36
        result = utils.get_data_dir()
 
37
        self.assertEqual(expected, result)
 
38
 
 
39
    def test_get_data_file(self):
 
40
        """The path for a data file is correctly retrieved."""
 
41
        dummy_dir = '/yadda/yadda'
 
42
        dummy_file = 'test.png'
 
43
        self.patch(utils, 'get_data_dir', lambda: dummy_dir)
 
44
        result = utils.get_data_file(dummy_file)
 
45
        self.assertEqual(os.path.join(dummy_dir, dummy_file), result)