aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-13 10:19:20 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-13 10:19:20 +0100
commitaa343e46247b6a55bd0d26dad1d0b9dabaf04851 (patch)
tree5e16f29164af9d36a33d6a115248df49717885b1 /ctrack/register
parent29028b60b46693c2ad9e786a61bd5e94bf6c7fa6 (diff)
first VERY BASIC view test working
Diffstat (limited to 'ctrack/register')
-rw-r--r--ctrack/register/templates/single_datetime_event_create.html4
-rw-r--r--ctrack/register/tests/test_views.py35
-rw-r--r--ctrack/register/urls.py26
3 files changed, 51 insertions, 14 deletions
diff --git a/ctrack/register/templates/single_datetime_event_create.html b/ctrack/register/templates/single_datetime_event_create.html
new file mode 100644
index 0000000..94a5162
--- /dev/null
+++ b/ctrack/register/templates/single_datetime_event_create.html
@@ -0,0 +1,4 @@
+{% extends "base.html" %}
+{% block content %}
+ {{ form }}
+{% endblock %}
diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py
index 51fceac..089cb9e 100644
--- a/ctrack/register/tests/test_views.py
+++ b/ctrack/register/tests/test_views.py
@@ -1,18 +1,39 @@
import pytest
+from django.test import Client
+from django.urls import reverse
from ctrack.register.views import SingleDateTimeEventCreate
+from ctrack.users.models import User
pytestmark = pytest.mark.django_db
-class TestSingleDateFormView:
- def test_single_datetime_event_form(self, user, request_factory):
+class TestMeetingEventFormView:
+ def test_add_meeting_form(self, user):
+ client = Client()
+ client.force_login(user)
+ url = reverse("register:event_create_singledatetime")
+ response = client.get(url)
+ assert response.status_code == 200
+
+ form = response.context_data["form"]
+ assert not form.is_bound
+ expected_fields = [
+ "type_descriptor",
+ "short_description",
+ "datetime",
+ "comments",
+ "location",
+ ]
+ for field in expected_fields:
+ assert field in form.fields
+ # We're keeping the use field out of the form
+ assert "user" not in form.fields
+
+ def test_user_passed_as_kwarg(self, user, request_factory):
view = SingleDateTimeEventCreate()
request = request_factory.get("/register/event/create-single-datetime/")
request.user = user
view.request = request
- response = SingleDateTimeEventCreate.as_view()(request)
- assert response.status_code == 200
- assert not response.context_data["form"].is_bound
- for k in ["type_descriptor", "short_description", "datetime", "comments", "location"]:
- assert k in response.context_data["form"].fields
+ view.setup(request)
+ assert "user" in view.get_form_kwargs()
diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py
index d5c21cb..fb05a02 100644
--- a/ctrack/register/urls.py
+++ b/ctrack/register/urls.py
@@ -1,21 +1,33 @@
from django.urls import path
-from ctrack.register.views import EngagementEventCreate, EngagementEventDelete, EngagementEventCreateFromCaf, \
- SingleDateTimeEventCreate
+from ctrack.register.views import (
+ EngagementEventCreate,
+ EngagementEventDelete,
+ EngagementEventCreateFromCaf,
+ SingleDateTimeEventCreate,
+)
app_name = "register"
urlpatterns = [
path(
- "engagement-event/create/from-org/<slug:slug>", view=EngagementEventCreate.as_view(), name="create",
+ "engagement-event/create/from-org/<slug:slug>",
+ view=EngagementEventCreate.as_view(),
+ name="create",
),
path(
- "engagement-event/delete/<int:pk>/for-org/<slug:slug>", view=EngagementEventDelete.as_view(), name="ee_delete"
+ "engagement-event/delete/<int:pk>/for-org/<slug:slug>",
+ view=EngagementEventDelete.as_view(),
+ name="ee_delete",
),
path(
- "engagement-event/create/from-caf/<int:caf_id>", view=EngagementEventCreateFromCaf.as_view(), name="create_from_caf"
+ "engagement-event/create/from-caf/<int:caf_id>",
+ view=EngagementEventCreateFromCaf.as_view(),
+ name="create_from_caf",
),
path(
- "event/create-single-datetime", view=SingleDateTimeEventCreate.as_view(), name="event_create_singledatetime"
- )
+ "event/create-single-datetime",
+ view=SingleDateTimeEventCreate.as_view(),
+ name="event_create_singledatetime",
+ ),
]