# Path: habitat/utils/immortal_changes.py
# class Consumer(couchdbkit.Consumer):
#     def wait(self, callback, **kwargs):
#         def wrapped_callback(changes):


import mox
import couchdbkit
import time
from nose.tools import assert_raises
from ...utils import immortal_changes

    def sleep(self, length):
        raise NotImplementedError

class TestParser(object):
    def setup(self):
        self.m = mox.Mox()

        self.consumer = immortal_changes.Consumer(None,
            backend='habitat.tests.test_utils.'
                    'test_immortal_changes.DummyConsumer')
        assert isinstance(self.consumer._consumer, DummyConsumer)
        self.m.StubOutWithMock(self.consumer._consumer, "wait")

        assert immortal_changes.time == time
        immortal_changes.time = DummyTimeModule()
        self.m.StubOutWithMock(immortal_changes.time, "sleep")

        self.m.StubOutWithMock(immortal_changes.logger, "exception")

        # for brevity.
        self.backend = self.consumer._consumer.wait
        self.sleep = immortal_changes.time.sleep
        self.exc = immortal_changes.logger.exception
        self.cb = self.m.CreateMockAnything()

    def teardown(self):
        self.m.UnsetStubs()

        assert isinstance(immortal_changes.time, DummyTimeModule)

# Path: habitat/utils/immortal_changes.py
# class Consumer(couchdbkit.Consumer):
#     def wait(self, callback, **kwargs):
#         def wrapped_callback(changes):


# Path: habitat/tests/test_utils/test_immortal_changes.py
import mox
import couchdbkit
import time
from nose.tools import assert_raises
from ...utils import immortal_changes


    def sleep(self, length):
        raise NotImplementedError

class TestParser(object):
    def setup(self):
        self.m = mox.Mox()

        self.consumer = immortal_changes.Consumer(None,
            backend='habitat.tests.test_utils.'
                    'test_immortal_changes.DummyConsumer')
        assert isinstance(self.consumer._consumer, DummyConsumer)
        self.m.StubOutWithMock(self.consumer._consumer, "wait")

        assert immortal_changes.time == time
        immortal_changes.time = DummyTimeModule()
        self.m.StubOutWithMock(immortal_changes.time, "sleep")

        self.m.StubOutWithMock(immortal_changes.logger, "exception")

        # for brevity.
        self.backend = self.consumer._consumer.wait
        self.sleep = immortal_changes.time.sleep
        self.exc = immortal_changes.logger.exception
        self.cb = self.m.CreateMockAnything()

    def teardown(self):
        self.m.UnsetStubs()

        assert isinstance(immortal_changes.time, DummyTimeModule)

        immortal_changes.time = time