def test_get_decision(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_id='do_it', activity_type=activity_type)
     decision_dict = d.get_decision()
     decision_attributes = decision_dict['scheduleActivityTaskDecisionAttributes']
     assert decision_dict['decisionType'] == 'ScheduleActivityTask'
     assert decision_attributes['activityType']['name'] == 'at'
     assert decision_attributes['activityType']['version'] == '1'
     assert decision_attributes['activityId'] == d.activity_id
Exemple #2
0
 def test_get_decision(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_id='do_it',
                              activity_type=activity_type)
     decision_dict = d.get_decision()
     decision_attributes = decision_dict[
         'scheduleActivityTaskDecisionAttributes']
     assert decision_dict['decisionType'] == 'ScheduleActivityTask'
     assert decision_attributes['activityType']['name'] == 'at'
     assert decision_attributes['activityType']['version'] == '1'
     assert decision_attributes['activityId'] == d.activity_id
Exemple #3
0
    def test_complete(self, mocker):
        client_mock = type("ClientMock", (object, ),
                           {'respond_decision_task_completed': Mock()})
        mocker.patch('floto.api.Swf.client',
                     new_callable=PropertyMock,
                     return_value=client_mock())
        mocker.patch('floto.decisions.ScheduleActivityTask.get_decision',
                     return_value='my_dec')

        d = floto.decider.Base()
        d.decisions.append(ScheduleActivityTask())

        d.complete()
        ScheduleActivityTask.get_decision.assert_called_once_with()

        args = {'decisions': ['my_dec'], 'taskToken': d.task_token}
        floto.api.Swf.client.respond_decision_task_completed.assert_called_once_with(
            **args)
        assert d.decisions == []
 def test_decision_attributes_wo_activity_type(self):
     d = ScheduleActivityTask()
     with pytest.raises(ValueError):
         d.decision_attributes()
 def test_assert_required_fields_raises_witout_value_in_sub_dict(self):
     dictionary = {'key':{'key2':None}}
     d = ScheduleActivityTask()
     with pytest.raises(KeyError) as e:
         d.assert_required_fields(dictionary, ['key', 'key.key2'])
 def test_assert_required_fields_raises(self):
     dictionary = {'key':'val'}
     d = ScheduleActivityTask()
     with pytest.raises(KeyError) as e:
         d.assert_required_fields(dictionary, ['key','key.key2'])
 def test_decision_attribute_default_activity_id(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_type=activity_type)
     activity_id = activity_type.name + '_' + activity_type.version
     assert d.decision_attributes()['activityId'] == activity_id 
Exemple #8
0
 def test_decision_attribute_default_activity_id(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_type=activity_type)
     activity_id = activity_type.name + '_' + activity_type.version
     assert d.decision_attributes()['activityId'] == activity_id
 def test_path_in_dictionary(self):
     dictionary = {'key':'value'}
     d = ScheduleActivityTask()
     assert d.path_in_dictionary(dictionary, 'key')
     assert not d.path_in_dictionary(dictionary, 'key2')
Exemple #10
0
 def test_task_list_in_decision_attributes(self, activity_type):
     t = ScheduleActivityTask(activity_type=activity_type, task_list='tl')
     d = t._get_decision()['scheduleActivityTaskDecisionAttributes']
     assert d['taskList']['name'] == 'tl'
Exemple #11
0
 def test_decision_attributes_with_input_in_init(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_type=activity_type,
                              input={'foo': 'bar'})
     assert json.loads(d.decision_attributes()['input'])['foo'] == 'bar'
Exemple #12
0
 def test_decision_attributes_wo_activity_type(self):
     d = ScheduleActivityTask()
     with pytest.raises(ValueError):
         d.decision_attributes()
Exemple #13
0
 def test_assert_required_fields_raises_witout_value_in_sub_dict(self):
     dictionary = {'key': {'key2': None}}
     d = ScheduleActivityTask()
     with pytest.raises(KeyError) as e:
         d.assert_required_fields(dictionary, ['key', 'key.key2'])
Exemple #14
0
 def test_assert_required_fields_raises(self):
     dictionary = {'key': 'val'}
     d = ScheduleActivityTask()
     with pytest.raises(KeyError) as e:
         d.assert_required_fields(dictionary, ['key', 'key.key2'])
 def test_decision_attributes_with_input_in_init(self):
     activity_type = ActivityType(domain='d', name='at', version='1')
     d = ScheduleActivityTask(activity_type=activity_type, input={'foo':'bar'})
     assert json.loads(d.decision_attributes()['input'])['foo'] == 'bar'
 def test_task_list_in_decision_attributes(self, activity_type):
     t = ScheduleActivityTask(activity_type=activity_type, task_list='tl')
     d = t._get_decision()['scheduleActivityTaskDecisionAttributes']
     assert d['taskList']['name'] == 'tl'
 def test_path_in_dictionary_several_keys(self):
     dictionary = {'key':{'key2':'val'}}
     d = ScheduleActivityTask()
     assert d.path_in_dictionary(dictionary, 'key.key2')