aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/register/tests')
-rw-r--r--ctrack/register/tests/test_forms.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py
new file mode 100644
index 0000000..0383fa3
--- /dev/null
+++ b/ctrack/register/tests/test_forms.py
@@ -0,0 +1,37 @@
+import pytest
+
+from ..forms import AddMeetingForm
+
+pytestmark = pytest.mark.django_db
+
+
+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."]
+ }