Ejemplo n.º 1
0
def test_worker_infinite_loop_on_external(monkeypatch):
    """There is no worker for external activities.
    """

    external_activity = activity.ExternalActivity(timeout=10)
    current_run = external_activity.run
    spy = MagicMock()

    def run():
        spy()
        return current_run()

    monkeypatch.setattr(external_activity, 'run', run)
    activity.worker_runner(external_activity)

    # This test might not fail, but it will hang the test suite since it is
    # going to trigger an infinite loop.
    assert spy.call_count == 1
Ejemplo n.º 2
0
def test_worker_infinite_loop_on_external(monkeypatch):
    """There is no worker for external activities.
    """

    external_activity = activity.ExternalActivity(timeout=10)
    current_run = external_activity.run
    spy = MagicMock()

    def run():
        spy()
        return current_run()

    monkeypatch.setattr(external_activity, 'run', run)
    activity.worker_runner(external_activity)

    # This test might not fail, but it will hang the test suite since it is
    # going to trigger an infinite loop.
    assert spy.call_count == 1
Ejemplo n.º 3
0
def test_worker_infinite_loop():
    """Test the worker runner.
    """

    spy = MagicMock()

    class Activity:
        def __init__(self):
            self.count = 0

        def run(self):
            spy()
            self.count = self.count + 1
            if self.count < 5:
                return True
            return False

    activity.worker_runner(Activity())
    assert spy.called
    assert spy.call_count == 5
Ejemplo n.º 4
0
def test_worker_infinite_loop():
    """Test the worker runner.
    """

    spy = MagicMock()

    class Activity:
        def __init__(self):
            self.count = 0

        def run(self):
            spy()
            self.count = self.count + 1
            if self.count < 5:
                return True
            return False

    activity.worker_runner(Activity())
    assert spy.called
    assert spy.call_count == 5
Ejemplo n.º 5
0
def test_worker_infinite_loop():
    """Test the worker runner.
    """

    spy = MagicMock()

    class Activity:
        def __init__(self):
            self.count = 0

        def run(self, identity=None):
            spy()
            self.count = self.count + 1
            if self.count < 5:
                return True
            return False

    activity_worker = Activity()
    activity_worker.name = 'activity_name'
    activity_worker.logger = MagicMock()
    activity.worker_runner(activity_worker)
    assert spy.called
    assert spy.call_count == 5
Ejemplo n.º 6
0
def test_worker_infinite_loop():
    """Test the worker runner.
    """

    spy = MagicMock()

    class Activity:
        def __init__(self):
            self.count = 0

        def run(self, identity=None):
            spy()
            self.count = self.count + 1
            if self.count < 5:
                return True
            return False

    activity_worker = Activity()
    activity_worker.name = 'activity_name'
    activity_worker.logger = MagicMock()
    activity.worker_runner(activity_worker)
    assert spy.called
    assert spy.call_count == 5