~statik/ubuntu/karmic/ubuntuone-client/spbranch-experiment

« back to all changes in this revision

Viewing changes to tests/nautilus/test_storage.py

  • Committer: Rodney Dawes
  • Date: 2009-05-12 13:36:05 UTC
  • Revision ID: rodney.dawes@canonical.com-20090512133605-6aqs6e8xnnmp5u1p
        Import the code
        Hook up lint/trial tests in setup.py
        Use icontool now instead of including the render script
        Add missing python-gnome2-desktop to package dependencies
        Update debian/rules to fix the icon cache issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# canonical.ubuntuone.nautilus.tests.test_storage
 
2
#
 
3
# Author: Tim Cole <tim.cole@canonical.com>
 
4
#
 
5
# Copyright 2009 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
"""Tests for the storage-related nautilus extension classes."""
 
19
 
 
20
from __future__ import with_statement
 
21
from unittest import TestCase
 
22
from canonical.ubuntuone.nautilus.storage import StorageBarProvider
 
23
from contrib.mocker import Mocker, expect
 
24
 
 
25
 
 
26
class TestStorageBarProvider(TestCase):
 
27
    """Test the Storage location bar provider."""
 
28
 
 
29
    def setUp(self):
 
30
        """Sets up the test."""
 
31
        self.mocker = Mocker()
 
32
        self.window = self.mocker.mock()
 
33
        self.storagefs_test = self.mocker.mock()
 
34
        self.provider = None
 
35
 
 
36
    def tearDown(self):
 
37
        """Tears down a test."""
 
38
        self.mocker.restore()
 
39
        self.mocker.verify()
 
40
 
 
41
    def replay(self):
 
42
        """Starts replay phase and creates the storage bar provider."""
 
43
        self.mocker.replay()
 
44
        self.provider = StorageBarProvider(is_storagefs=self.storagefs_test)
 
45
    
 
46
    def testInstantiation(self):
 
47
        """Make sure that instantiation works."""
 
48
        self.replay()
 
49
 
 
50
    def testNoWidgetForNonFileURIs(self):
 
51
        """Make sure that we don't return a widget for non-file URIs."""
 
52
        url = "http://www.google.com/"
 
53
        self.replay()
 
54
        self.assert_(self.provider.get_widget(url, self.window) is None,
 
55
                     "Should not return a widget for a non-file URI")
 
56
 
 
57
    def testNoWidgetOutsideStorageFS(self):
 
58
        """Make sure that we don't return a widget for regular directories."""
 
59
        url = "file:///etc/"
 
60
        expect(self.storagefs_test("/etc/")).result(False)
 
61
        self.replay()
 
62
        self.assert_(self.provider.get_widget(url, self.window) is None,
 
63
                     "Should not return a widget outside storagefs")
 
64
 
 
65
    def testWidgetInsideStorageFS(self):
 
66
        """Make sure that we do return a widget for storagefs directories."""
 
67
        url = "file:///blah/"
 
68
        expect(self.storagefs_test("/blah/")).result(True)
 
69
        self.replay()
 
70
        self.assert_(self.provider.get_widget(url, self.window) is not None)