aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/register/tests/test_forms.py31
-rw-r--r--ctrack/register/tests/test_models.py2
-rw-r--r--ctrack/register/tests/test_views.py21
3 files changed, 47 insertions, 7 deletions
diff --git a/ctrack/register/tests/test_forms.py b/ctrack/register/tests/test_forms.py
index 2307a20..e392aca 100644
--- a/ctrack/register/tests/test_forms.py
+++ b/ctrack/register/tests/test_forms.py
@@ -22,7 +22,26 @@ def test_init(user):
"comments": "Test Comments",
"location": "Transient Moats",
},
- user=user,
+ user=user, org_slug=None
+ )
+ assert form.is_valid()
+
+
+def test_simple_event_limited_to_org_participants(user, org, person):
+ person.organisation = org
+ person.save()
+ people_from_org = org.get_people()
+ form = CreateSimpleDateTimeEventForm(
+ {
+ "type_descriptor": "PHONE_CALL",
+ "short_description": "Test Short Description",
+ "datetime": "2010-10-10 10:00",
+ "requested_response_date": "2020-12-24",
+ "response_received_date": "2020-12-25",
+ "participants": people_from_org,
+ "url": "https://fake.url.com",
+ "comments": "Test Comments not needed"
+ }, user=user, org_slug=org.slug
)
assert form.is_valid()
@@ -35,7 +54,7 @@ def test_cannot_create_disallowed_single_date_event_type_with_form(user):
"datetime": "2020-10-10",
"comments": "Test Comments",
},
- user=user,
+ user=user, org_slug=None
)
assert form.is_valid() is False
assert form.errors == {
@@ -55,7 +74,7 @@ def test_create_simple_datetime_event(user):
"response_received_date": "2020-12-25",
"url": "https://fake.url.com",
"comments": "Test Comments not needed"
- }, user=user,
+ }, user=user, org_slug=None
)
assert form.is_valid()
@@ -71,7 +90,7 @@ def test_create_private_note(user):
"url": "https://fake.url.com",
"private": True,
"comments": "Test Comments not needed"
- }, user=user,
+ }, user=user, org_slug=None
)
assert form.is_valid()
@@ -85,7 +104,7 @@ def test_response_date_cannot_be_before_date(user):
"requested_response_date": "2009-12-24",
"response_received_date": None,
"comments": "Test Comments not needed"
- }, user=user,
+ }, user=user, org_slug=None
)
assert not form.is_valid()
assert form.errors == {"__all__": ["Requested response cannot be before date."]}
@@ -99,7 +118,7 @@ def test_meeting_blank_data(user):
"short_description": "Test short description",
"comments": "Test Comments",
},
- user=user,
+ user=user, org_slug=None
)
assert form.is_valid() is False
assert form.errors == {"datetime": ["This field is required."]}
diff --git a/ctrack/register/tests/test_models.py b/ctrack/register/tests/test_models.py
index 1f8923b..e4f6a8d 100644
--- a/ctrack/register/tests/test_models.py
+++ b/ctrack/register/tests/test_models.py
@@ -171,7 +171,7 @@ def test_single_datetime_event(person, user, allowed_type):
event = SingleDateTimeEvent.objects.create(
type_descriptor=allowed_type,
short_description="Important event",
- url = "http://fake.url.com",
+ url="http://fake.url.com",
requested_response_date="2021-01-24",
response_received_date=None,
datetime="2020-10-10T15:00",
diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py
index b806165..da26d50 100644
--- a/ctrack/register/tests/test_views.py
+++ b/ctrack/register/tests/test_views.py
@@ -108,6 +108,27 @@ class TestSingleDateTimeEvent:
view.setup(request)
assert "user" in view.get_form_kwargs()
+ def test_can_create_simple_event_with_org_slug(self, user, org, client):
+ slug = org.slug
+ url = f"/register/event/create-simple-event-from-org/{slug}"
+ client.force_login(user)
+ response = client.get(url)
+ html = response.content.decode("utf-8")
+ assert response.status_code == 200
+ test_case.assertInHTML("Create a new simple event", html)
+
+
+ @pytest.mark.skip("Until we know what we're doing")
+ def test_org_passed_as_kwarg(self, user, org, request_factory):
+ slug = org.slug
+ view = SingleDateTimeEventCreate()
+ url = f"/register/event/create-simple-event-from-org/{slug}"
+ request = request_factory.get(url)
+ request.user = user
+ view.request = request
+ view.setup(request)
+ assert "org" in view.get_form_kwargs()
+
class TestSingleDateCAFEventViews:
def test_initial_caf_received(self, client):