aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/tests/test_forms.py
blob: 9a0f5410e7faa29d51da4e5d7c36800923a57de9 (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
import pytest

from ..forms import AddMeetingForm

pytestmark = pytest.mark.django_db


# TODO this test and the form code needs to be amended to save created_by and update_by
#   on the model

def test_init(user):
    """Here we test that we can pass in the user value from the view.
    We don't want that to be field in the form.
    """
    form = AddMeetingForm({
        "type_descriptor": "Meeting",  # Must be Meeting as that is in the choices param
        "short_description": "Test short description",
        "datetime": "2010-10-10T13:00",
        "comments": "Test Comments",
        "location": "Transient Moabs"
    },
        user=user,
    )
    assert form.is_valid()


def test_blank_data(user):
    """Missing location and datetime fields which are required."""
    form = AddMeetingForm({
        "type_descriptor": "Meeting",
        "short_description": "Test short description",
        "comments": "Test Comments",
    },
        user=user,
    )
    assert form.is_valid() is False
    assert form.errors == {
        "location": ["This field is required."],
        "datetime": ["This field is required."]
    }