~ubuntu-branches/ubuntu/oneiric/ubuntuone-client/oneiric

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_localrescan.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2010-08-04 10:08:20 UTC
  • mto: This revision was merged to the branch mainline in revision 41.
  • Revision ID: james.westby@ubuntu.com-20100804100820-m88dfedh2sa3hi3v
Tags: upstream-1.3.6
ImportĀ upstreamĀ versionĀ 1.3.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import with_statement
21
21
 
22
 
import unittest
 
22
import logging
23
23
import os
24
24
import shutil
 
25
import unittest
25
26
 
26
27
from twisted.internet import defer, reactor
27
28
 
2095
2096
        return self._deferred
2096
2097
 
2097
2098
 
 
2099
class BrokenNodesTests(TwistedBase):
 
2100
    """Test that LR logs all broken nodes at start."""
 
2101
 
 
2102
    def setUp(self):
 
2103
        """Set up."""
 
2104
        TwistedBase.setUp(self)
 
2105
        self.handler = testcase.MementoHandler()
 
2106
        log = logging.getLogger('ubuntuone.SyncDaemon.local_rescan')
 
2107
        log.addHandler(self.handler)
 
2108
 
 
2109
    def test_nothing(self):
 
2110
        """No broken nodes."""
 
2111
        def check(_):
 
2112
            """Check"""
 
2113
            self.assertFalse(self.handler.check_info('Broken node'))
 
2114
 
 
2115
        self.startTest(check)
 
2116
        return self.deferred
 
2117
 
 
2118
    def test_one(self):
 
2119
        """Something in the broken nodes list."""
 
2120
        path = os.path.join(self.share.path, "brokennodepath")
 
2121
        mdid = self.fsm.create(path, self.share.volume_id, node_id="uuid")
 
2122
        self.fsm.set_by_mdid(mdid, dirty=True, local_hash='foo')
 
2123
 
 
2124
        def check(_):
 
2125
            """Check"""
 
2126
            self.assertTrue(self.handler.check_info('Broken node',
 
2127
                                                    'brokennodepath', mdid))
 
2128
 
 
2129
        self.startTest(check)
 
2130
        return self.deferred
 
2131
 
 
2132
    def test_several(self):
 
2133
        """Several in the broken nodes list."""
 
2134
        path1 = os.path.join(self.share.path, "brokenpath1")
 
2135
        mdid1 = self.fsm.create(path1, self.share.volume_id, node_id='uuid1')
 
2136
        self.fsm.set_by_mdid(mdid1, dirty=True, local_hash='foo')
 
2137
        path2 = os.path.join(self.share.path, "brokenpath2")
 
2138
        mdid2 = self.fsm.create(path2, self.share.volume_id, node_id='uuid2')
 
2139
        self.fsm.set_by_mdid(mdid2, dirty=True, local_hash='foo')
 
2140
 
 
2141
        def check(_):
 
2142
            """Check"""
 
2143
            self.assertTrue(self.handler.check_info('Broken node',
 
2144
                                                    'brokenpath1', mdid1))
 
2145
 
 
2146
            self.assertTrue(self.handler.check_info('Broken node',
 
2147
                                                    'brokenpath2', mdid2))
 
2148
 
 
2149
        self.startTest(check)
 
2150
        return self.deferred
 
2151
 
 
2152
 
2098
2153
def test_suite():
2099
2154
    # pylint: disable-msg=C0111
2100
2155
    return unittest.TestLoader().loadTestsFromName(__name__)