~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

Viewing changes to tests/u1sync/test_client.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-02-11 16:18:11 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20110211161811-lbelxu332e8r2dov
Tags: 1.5.4-0ubuntu1
* New upstream release.
  - Files still get downloaded from unsubscribed folder (LP: #682878)
  - Add subscription capabilities to shares (LP: #708335)
  - Nautilus offers Publish option within other's shares (LP: #712674)
  - Shares dir name may not be unique (LP: #715776)
  - Send a notification when new Volume is available (LP: #702055)
  - Add messaging menu entry for new Volumes (LP: #702075)
  - Aggregate notifications for completed operations (LP: #702128)
  - Send a notification for new Share offers (LP: #702138)
  - Add messaging menu entry for new Share offers (LP: #702144)
* Remove ubuntuone-client-tools as u1sync has been moved out.
* Simplify python package as we don't have multiple python packages now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Author: Facundo Batista <facundo@canonical.com>
3
 
#
4
 
# Copyright 2010 Canonical Ltd.
5
 
#
6
 
# This program is free software: you can redistribute it and/or modify it
7
 
# under the terms of the GNU General Public License version 3, as published
8
 
# by the Free Software Foundation.
9
 
#
10
 
# This program is distributed in the hope that it will be useful, but
11
 
# WITHOUT ANY WARRANTY; without even the implied warranties of
12
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
 
# PURPOSE.  See the GNU General Public License for more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License along
16
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
"""Test the client code."""
19
 
 
20
 
from mocker import Mocker
21
 
from twisted.trial.unittest import TestCase
22
 
 
23
 
from ubuntuone.u1sync import client
24
 
 
25
 
 
26
 
class SyncStorageClientTest(TestCase):
27
 
    """Test the SyncStorageClient."""
28
 
 
29
 
    def test_conn_made_call_parent(self):
30
 
        """The connectionMade method should call the parent."""
31
 
        # set up everything
32
 
        called = []
33
 
        self.patch(client.StorageClient, 'connectionMade',
34
 
                   lambda s: called.append(True))
35
 
        c = client.SyncStorageClient()
36
 
        mocker = Mocker()
37
 
        obj = mocker.mock()
38
 
        obj.current_protocol
39
 
        mocker.result(None)
40
 
        obj.current_protocol = c
41
 
        obj.observer.connected()
42
 
        c.factory = obj
43
 
 
44
 
        # call and test
45
 
        with mocker:
46
 
            c.connectionMade()
47
 
        self.assertTrue(called)
48
 
 
49
 
    def test_conn_lost_call_parent(self):
50
 
        """The connectionLost method should call the parent."""
51
 
        # set up everything
52
 
        called = []
53
 
        self.patch(client.StorageClient, 'connectionLost',
54
 
                   lambda s, r: called.append(True))
55
 
        c = client.SyncStorageClient()
56
 
        mocker = Mocker()
57
 
        obj = mocker.mock()
58
 
        obj.current_protocol
59
 
        mocker.result(None)
60
 
        c.factory = obj
61
 
 
62
 
        # call and test
63
 
        with mocker:
64
 
            c.connectionLost()
65
 
        self.assertTrue(called)
66