1
# canonical.ubuntuone.nautilus.tests.test_storage
3
# Author: Tim Cole <tim.cole@canonical.com>
5
# Copyright 2009 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/>.
18
"""Tests for the storage-related nautilus extension classes."""
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
26
class TestStorageBarProvider(TestCase):
27
"""Test the Storage location bar provider."""
30
"""Sets up the test."""
31
self.mocker = Mocker()
32
self.window = self.mocker.mock()
33
self.storagefs_test = self.mocker.mock()
37
"""Tears down a test."""
42
"""Starts replay phase and creates the storage bar provider."""
44
self.provider = StorageBarProvider(is_storagefs=self.storagefs_test)
46
def testInstantiation(self):
47
"""Make sure that instantiation works."""
50
def testNoWidgetForNonFileURIs(self):
51
"""Make sure that we don't return a widget for non-file URIs."""
52
url = "http://www.google.com/"
54
self.assert_(self.provider.get_widget(url, self.window) is None,
55
"Should not return a widget for a non-file URI")
57
def testNoWidgetOutsideStorageFS(self):
58
"""Make sure that we don't return a widget for regular directories."""
60
expect(self.storagefs_test("/etc/")).result(False)
62
self.assert_(self.provider.get_widget(url, self.window) is None,
63
"Should not return a widget outside storagefs")
65
def testWidgetInsideStorageFS(self):
66
"""Make sure that we do return a widget for storagefs directories."""
68
expect(self.storagefs_test("/blah/")).result(True)
70
self.assert_(self.provider.get_widget(url, self.window) is not None)