~ubuntu-branches/ubuntu/utopic/kazoo/utopic-proposed

« back to all changes in this revision

Viewing changes to kazoo/tests/test_gevent_handler.py

  • Committer: Package Import Robot
  • Author(s): Neil Williams
  • Date: 2013-08-26 06:26:20 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130826062620-dv79eayvq78028jb
Tags: 1.2.1-1
* New upstream release.
* Fix sphinx documentation build on clean systems (added
  python-gevent to Build-Depends and patched config).
* Bumped standards version to 3.9.4. No changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        h.dispatch_callback(call1)
78
78
        ev.wait()
79
79
 
80
 
    def test_peeking(self):
81
 
        from kazoo.handlers.gevent import _PeekableQueue
82
 
        from kazoo.handlers.gevent import Empty
83
 
        queue = _PeekableQueue()
84
 
        queue.put('fred')
85
 
        eq_(queue.peek(), 'fred')
86
 
        eq_(queue.get(), 'fred')
87
 
 
88
 
        @raises(Empty)
89
 
        def testit():
90
 
            queue.peek(block=False)
91
 
        testit()
92
 
 
93
 
    def test_peekable_queue_switching(self):
94
 
        import gevent
95
 
        h = self._makeOne()
96
 
        queue = h.peekable_queue()
97
 
 
98
 
        def getter():
99
 
            peeked = queue.peek(True, timeout=5)
100
 
            got = queue.get()
101
 
            eq_(peeked, got)
102
 
            return got
103
 
 
104
 
        # try to make sure getter is running before putting
105
 
        getter_thread = gevent.spawn(getter)
106
 
        gevent.spawn_later(0, queue.put, 'fred')
107
 
 
108
 
        eq_(getter_thread.get(), 'fred')
109
 
 
110
 
        # repeat the process to make sure the queue signalling mechanism
111
 
        # is reset correctly
112
 
        getter_thread = gevent.spawn(getter)
113
 
        gevent.spawn_later(0, queue.put, 'fred')
114
 
 
115
 
        eq_(getter_thread.get(), 'fred')
116
 
 
117
80
 
118
81
class TestBasicGeventClient(KazooTestCase):
119
82