예제 #1
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
예제 #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
예제 #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 == []
예제 #4
0
 def test_decision_attributes_wo_activity_type(self):
     d = ScheduleActivityTask()
     with pytest.raises(ValueError):
         d.decision_attributes()
예제 #5
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'])
예제 #6
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'])
예제 #7
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 
예제 #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')
예제 #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'
예제 #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'
예제 #12
0
 def test_decision_attributes_wo_activity_type(self):
     d = ScheduleActivityTask()
     with pytest.raises(ValueError):
         d.decision_attributes()
예제 #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'])
예제 #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'])
예제 #15
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'
예제 #16
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'
예제 #17
0
 def test_path_in_dictionary_several_keys(self):
     dictionary = {'key':{'key2':'val'}}
     d = ScheduleActivityTask()
     assert d.path_in_dictionary(dictionary, 'key.key2')