def test_get_or_create_creates(self): x = Task.get_or_create(self.signal, dict(some_kwarg='foo'), logger=logging.getLogger('TaskX')) y = Task.get_or_create(self.signal, dict(some_kwarg='bar'), logger=logging.getLogger('TaskY')) assert x is not y
def test_not_eq(self): x = Task(self.signal, dict(some_kwarg='foo', logger=logging.getLogger('TaskX'))) y = Task(self.signal, dict(some_kwarg='bar', logger=logging.getLogger('TaskY'))) assert x != y
def get_task_mock(self, *methods): task_mock = Task(self.signal) for method in methods: setattr(task_mock, method, mock.Mock()) return task_mock
def test_semaphore(self, inspect): slot = mock.Mock() slot.side_effect = lambda **k: time.sleep(.3) signal = Signal('tost') signal.connect(slot) x = Task.get_or_create(signal, dict(some_kwarg='foo')) y = Task.get_or_create(signal, dict(some_kwarg='foo')) eventlet.spawn(x) time.sleep(.1) eventlet.spawn(y) time.sleep(.1) assert slot.call_count == 1 time.sleep(.4) assert slot.call_count == 2
def get_task_mock(self, *methods, **kwargs): if kwargs.get('logger'): log = logging.getLogger('TestTask') else: log = None task_mock = Task(self.signal, logger=log) for method in methods: setattr(task_mock, method, mock.Mock()) return task_mock
def test_get_or_create_without_kwargs(self): t = Task.get_or_create(self.signal) assert t.kwargs == {}
def test_unicode(self): t = Task(self.signal, dict(some_kwarg='foo'), logger=logging.getLogger('TaskT')) assert str(t) == "Mock: {'some_kwarg': 'foo'}"
def test_get_or_create_creates(self): x = Task.get_or_create(self.signal, dict(some_kwarg='foo')) y = Task.get_or_create(self.signal, dict(some_kwarg='bar')) assert x is not y
def test_unicode(self): t = Task(self.signal, dict(some_kwarg='foo')) assert str(t) == "Mock: {'some_kwarg': 'foo'}"
def test_not_eq(self): x = Task(self.signal, dict(some_kwarg='foo')) y = Task(self.signal, dict(some_kwarg='bar')) assert x != y