From 8f15ce5ce6061f4c8c6fbb4f50ceae55981a1e7e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 13 Oct 2020 19:55:19 +0100 Subject: view test for missing required data --- ctrack/register/tests/test_views.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py index 0b01047..21496b4 100644 --- a/ctrack/register/tests/test_views.py +++ b/ctrack/register/tests/test_views.py @@ -1,14 +1,17 @@ import pytest from django.urls import reverse +from django.test import TestCase + +test_case = TestCase("run") from ctrack.register.views import SingleDateTimeEventCreate pytestmark = pytest.mark.django_db -class TestMeetingEventFormView: +class TestSingleDateTimeEvent: - def test_add_meeting_form(self, client): + def test_add_single_datetime_event_form(self, client): url = reverse("register:event_create_simple_event") response = client.get(url) assert response.status_code == 200 @@ -27,6 +30,21 @@ class TestMeetingEventFormView: # We're keeping the use field out of the form assert "user" not in form.fields + def test_add_incorrect_form_data_single_datetime(self, client): + url = reverse("register:event_create_simple_event") + data = { + "type_descriptor": "Meeting X", + "short_description": "Test Short Description", + "datetime": "2010-10-10", + "comments": "Blah...", + "location": "The Moon" + } + response = client.post(url, data) + assert response.status_code == 200 + html = response.content.decode("utf-8") + test_case.assertIn("Select a valid choice. Meeting X is not one of the available choices.", html) + + def test_user_passed_as_kwarg(self, user, request_factory): view = SingleDateTimeEventCreate() request = request_factory.get("/register/event/create-simple-event/") @@ -34,3 +52,9 @@ class TestMeetingEventFormView: view.request = request view.setup(request) assert "user" in view.get_form_kwargs() + +class TestSingleDateCAFEventViews: + + def test_initial_caf_recevied(self, client): + pass + -- cgit v1.2.3