Esempio n. 1
0
def test_sleep(m_get_context):
    m_decider = MagicMock(spec=Decider)
    m_decider.handle_execute_timer.return_value = 'Works'
    m_get_context.return_value = MagicMock(spec=DecisionContext, decider=m_decider)

    assert 'Works' == workflow_time.sleep(10)
    assert m_decider.handle_execute_timer.mock_calls == [call(10)]
Esempio n. 2
0
def test_sleep(m_get_context):
    m_decider = MagicMock(spec=Decider)
    m_decider.handle_execute_timer.return_value = 'Works'
    m_get_context.return_value = MagicMock(spec=DecisionContext,
                                           decider=m_decider)

    assert 'Works' == workflow_time.sleep(10)
    assert m_decider.handle_execute_timer.mock_calls == [call(10)]
Esempio n. 3
0
                def do_try_except():
                    arg_sum = 0
                    try:
                        arg_sum += yield BunchOfActivities.sum(arg1, arg2)
                        yield BunchOfActivities.throw()
                    except ActivityTaskFailedError as err:
                        if isinstance(err.cause, ValueError) \
                           and str(err.cause) == 'Hello-Error':

                            if err.event_id != 13 or err.activity_id != '2':
                                raise RuntimeError("Test Failed")
                            arg_sum += yield BunchOfActivities.sum(arg1, arg2)
                    yield workflow_time.sleep(1)
                    return_(arg_sum)
Esempio n. 4
0
 def execute(self):
     yield workflow_time.sleep(4)
     return_(self.msg)
Esempio n. 5
0
def test_sleep_no_context(m_get_context):
    m_get_context.side_effect = AttributeError()

    with pytest.raises(TypeError):
        workflow_time.sleep()
Esempio n. 6
0
def test_sleep_wrong_context():
    with pytest.raises(TypeError):
        workflow_time.sleep(10)
Esempio n. 7
0
def test_sleep_no_context(m_get_context):
    m_get_context.side_effect = AttributeError()

    with pytest.raises(TypeError):
        workflow_time.sleep()
Esempio n. 8
0
def test_sleep_wrong_context():
    with pytest.raises(TypeError):
        workflow_time.sleep(10)
Esempio n. 9
0
 def execute(self, arg1, arg2):
     yield workflow_time.sleep(2)
     arg_sum = yield self.activities_client.sum(arg1, arg2)
     return_(arg_sum)
Esempio n. 10
0
 def execute(self):
     yield workflow_time.sleep(4)
     return_(self.msg)
Esempio n. 11
0
 def execute(self):
     activity_future = self.activities_client.wrong_tasklist_activity()
     yield workflow_time.sleep(2)
     yield activity_future.cancel()
     yield activity_future
     return_(False)
Esempio n. 12
0
 def execute(self):
     self.activities_client.heartbeating_activity(5)
     yield workflow_time.sleep(1)
     self.cancel()
     return_(True)
Esempio n. 13
0
 def execute(self):
     activity_future = self.activities_client.heartbeating_activity(5)
     yield workflow_time.sleep(2)
     activity_future._activity_id = '100'  # set invalid ID
     yield activity_future.cancel()
     return_(False)
Esempio n. 14
0
 def execute(self):
     activity_future = self.activities_client.heartbeating_activity(10)
     yield workflow_time.sleep(2)
     yield activity_future.cancel()
     yield activity_future
     return_(False)