~rye/ubuntuone-client/stop-killing-thumbnails

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_eventqueue.py

  • Committer: Tarmac
  • Author(s): natalia.bidart at canonical
  • Date: 2009-11-24 21:17:01 UTC
  • mfrom: (278.1.1 fix-docstrings)
  • Revision ID: dobey@gnome.org-20091124211701-hveqsvkfmizuurwh
Replacing ''' by """ according to what PEP-8 and PEP-257 state.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# You should have received a copy of the GNU General Public License along
18
18
# with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
 
'''Tests for the Event Queue.'''
 
20
"""Tests for the Event Queue."""
21
21
 
22
22
import logging
23
23
import unittest
31
31
 
32
32
 
33
33
class BaseEQTestCase(testcase.BaseTwistedTestCase):
34
 
    ''' Setup an EQ for test. '''
 
34
    """ Setup an EQ for test. """
35
35
 
36
36
    def setUp(self):
37
 
        '''Setup the test.'''
 
37
        """Setup the test."""
38
38
        testcase.BaseTwistedTestCase.setUp(self)
39
39
        self.fsmdir = self.mktemp('fsmdir')
40
40
        self.partials_dir = self.mktemp('partials_dir')
50
50
        self.fs.register_eq(self.eq)
51
51
 
52
52
    def tearDown(self):
53
 
        '''Clean up the tests.'''
 
53
        """Clean up the tests."""
54
54
        testcase.BaseTwistedTestCase.tearDown(self)
55
55
        self.eq.shutdown()
56
56
 
57
57
 
58
58
class SubscriptionTests(BaseEQTestCase):
59
 
    '''Test to subscribe and unsubscribe to the EQ.'''
 
59
    """Test to subscribe and unsubscribe to the EQ."""
60
60
 
61
61
    def test_subscription(self):
62
 
        '''Test that subscription works.'''
 
62
        """Test that subscription works."""
63
63
        # pylint: disable-msg=W0212
64
64
        # simple one
65
65
        o = object()
73
73
        self.assertTrue(self.eq._listeners.count(o) == 1)
74
74
 
75
75
    def test_unsubscription(self):
76
 
        '''Test that unsubscription works.'''
 
76
        """Test that unsubscription works."""
77
77
        # pylint: disable-msg=W0212
78
78
        # simple one
79
79
        o = object()
105
105
 
106
106
 
107
107
class PushTests(BaseEQTestCase):
108
 
    '''Test the event distribution machinery.'''
 
108
    """Test the event distribution machinery."""
109
109
 
110
110
    def test_push_simple(self):
111
 
        '''Test that events can be pushed (not listening yet).'''
 
111
        """Test that events can be pushed (not listening yet)."""
112
112
        # not even an event
113
113
        self.assertRaises(TypeError, self.eq.push)
114
114
 
130
130
        self.eq.push("FS_FILE_MOVE", 1, path_to=2)
131
131
 
132
132
    def test_listened_pushs(self):
133
 
        '''Push events and listem them.'''
 
133
        """Push events and listem them."""
134
134
 
135
135
        # helper class, pylint: disable-msg=C0111
136
136
        class Create(object):
154
154
        self.eq.unsubscribe(c)
155
155
 
156
156
    def test_signatures(self):
157
 
        '''Check that the handle signatures are forced when passing.'''
 
157
        """Check that the handle signatures are forced when passing."""
158
158
 
159
159
        # helper class, pylint: disable-msg=C0111
160
160
        class Create(object):
185
185
 
186
186
 
187
187
class PushTestsWithCallback(BaseEQTestCase):
188
 
    '''Test the error handling in the event distribution machinery.'''
 
188
    """Test the error handling in the event distribution machinery."""
189
189
 
190
190
    def test_keep_going(self):
191
 
        ''' Check that if a listener raises an Exception or have a
 
191
        """ Check that if a listener raises an Exception or have a
192
192
        wrong signature, the next listeners are called.
193
 
        '''
 
193
        """
194
194
        d = defer.Deferred()
195
195
        # helper class, pylint: disable-msg=C0111
196
196
        class BadListener(object):
227
227
        return d
228
228
 
229
229
    def test_default_handler(self):
230
 
        ''' Check that handler_default is called. '''
 
230
        """ Check that handler_default is called. """
231
231
        d = defer.Deferred()
232
232
        # helper class, pylint: disable-msg=C0111
233
233
        class Listener(object):
303
303
 
304
304
 
305
305
class MuteFilterTests(unittest.TestCase):
306
 
    '''Tests the MuteFilter class.'''
 
306
    """Tests the MuteFilter class."""
307
307
 
308
308
    def setUp(self):
309
309
        self.mf = event_queue.MuteFilter()
310
310
 
311
311
    def test_empty(self):
312
 
        '''Nothing there.'''
 
312
        """Nothing there."""
313
313
        self.assertFalse(self.mf._cnt)
314
314
 
315
315
    def test_add_one(self):
316
 
        '''Adds one element.'''
 
316
        """Adds one element."""
317
317
        self.mf.add("foo")
318
318
        self.assertEqual(self.mf._cnt, dict(foo=1))
319
319
 
320
320
    def test_add_two_different(self):
321
 
        '''Adds two different elements.'''
 
321
        """Adds two different elements."""
322
322
        self.mf.add("foo")
323
323
        self.mf.add("bar")
324
324
        self.assertEqual(self.mf._cnt, dict(foo=1, bar=1))
325
325
 
326
326
    def test_add_two_equal(self):
327
 
        '''Adds one element twice.'''
 
327
        """Adds one element twice."""
328
328
        self.mf.add("foo")
329
329
        self.mf.add("foo")
330
330
        self.assertEqual(self.mf._cnt, dict(foo=2))
331
331
 
332
332
    def test_add_two_equal_and_third(self):
333
 
        '''Adds one element.'''
 
333
        """Adds one element."""
334
334
        self.mf.add("foo")
335
335
        self.mf.add("bar")
336
336
        self.mf.add("bar")
337
337
        self.assertEqual(self.mf._cnt, dict(foo=1, bar=2))
338
338
 
339
339
    def test_pop_simple(self):
340
 
        '''Pops one element.'''
 
340
        """Pops one element."""
341
341
        self.mf.add("foo")
342
342
        self.assertFalse(self.mf.pop("bar"))
343
343
        self.assertEqual(self.mf._cnt, dict(foo=1))
345
345
        self.assertFalse(self.mf._cnt)
346
346
 
347
347
    def test_pop_complex(self):
348
 
        '''Pops several elements.'''
 
348
        """Pops several elements."""
349
349
        # add several
350
350
        self.mf.add("foo")
351
351
        self.mf.add("bar")