File: test_forms.py

package info (click to toggle)
python-django-braces 1.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 484 kB
  • sloc: python: 2,680; makefile: 138; sh: 6
file content (28 lines) | stat: -rw-r--r-- 734 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from django import test
from django.contrib.auth.models import User

from . import forms


class TestUserKwargModelFormMixin(test.TestCase):
    """
    Tests for UserKwargModelFormMixin.
    """

    def test_without_user_kwarg(self):
        """
        It should be possible to create form without 'user' kwarg.

        In that case 'user' attribute should be set to None.
        """
        form = forms.FormWithUserKwarg()
        assert form.user is None

    def test_with_user_kwarg(self):
        """
        Form's 'user' attribute should be set to value passed as 'user'
        argument.
        """
        user = User(username="test")
        form = forms.FormWithUserKwarg(user=user)
        assert form.user is user