예제 #1
0
    def test_action_with_jinja(self):
        scenario = PicklableMock()
        scenario.id = 'name'
        scenario.version = '1.0'
        self.user.descriptions = {'scenarios': {'test_scenario': scenario}}
        items = {
            'event_type': 'type',
            'event_content': {
                'field_1': '{{ main_form.field_1 }}'
            },
            'results': '{{ message.name }}'
        }
        expected = Event(type='type',
                         results='CLIENT_INFO_RESPONSE',
                         content={'field_1': 'value_1'},
                         scenario='name',
                         scenario_version='1.0')

        action = AddHistoryEventAction(items)
        action.run(self.user, None, None)

        self.user.history.add_event.assert_called_once()
        self.user.history.add_event.assert_called_once_with(expected)
예제 #2
0
    def test_action_with_non_empty_scenario(self):
        scenario = PicklableMock()
        scenario.id = 'name'
        scenario.version = '1.0'
        self.user.descriptions = {'scenarios': {'test_scenario': scenario}}
        items = {
            'event_type': 'type',
            'event_content': {
                'foo': 'bar'
            },
            'results': 'result'
        }
        expected = Event(type='type',
                         results='result',
                         content={'foo': 'bar'},
                         scenario='name',
                         scenario_version='1.0')

        action = AddHistoryEventAction(items)
        action.run(self.user, None, None)

        self.user.history.add_event.assert_called_once()
        self.user.history.add_event.assert_called_once_with(expected)