示例#1
0
    def test_initial(self):
        """
        Test :py:meth:`.FormMixin.get_initial`.
        """
        mixin = FormMixin()
        mixin.initial = {'foo': 'bar'}

        self.assertEqual({'foo': 'bar'}, mixin.get_initial())
示例#2
0
    def test_initial(self):
        """
        Test :py:meth:`.FormMixin.get_initial`.
        """
        mixin = FormMixin()
        mixin.initial = {'foo': 'bar'}

        self.assertEqual({'foo': 'bar'}, mixin.get_initial())
示例#3
0
    def test_get_form_kwargs(self, request):
        """
        Test :py:meth:`.FormMixin.get_form_kwargs`.
        """
        request.form = {'foo': 'bar'}

        mixin = FormMixin()
        mixin.get_initial = Mock(return_value={'name': 'John'})

        self.assertEqual({
            'formdata': {'foo': 'bar'},
            'name': 'John',
        }, mixin.get_form_kwargs())
        mixin.get_initial.assert_called_once_with()
示例#4
0
    def test_get_form_kwargs(self, request):
        """
        Test :py:meth:`.FormMixin.get_form_kwargs`.
        """
        request.form = {'foo': 'bar'}

        mixin = FormMixin()
        mixin.get_initial = Mock(return_value={'name': 'John'})

        self.assertEqual({
            'formdata': {
                'foo': 'bar'
            },
            'name': 'John',
        }, mixin.get_form_kwargs())
        mixin.get_initial.assert_called_once_with()