aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-10-18 15:37:21 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-10-18 15:37:21 +0100
commitd6a3d976e0a7bd2bde93a5ea5543e9e68922520d (patch)
tree3d02114cb0d676a870959288f2281e61b541150b
parentd25f73ff06f3daa428e0e87f42b83d071a31cc02 (diff)
fixed some tests
-rw-r--r--ctrack/organisations/tests/factories.py13
-rw-r--r--ctrack/organisations/tests/test_factories.py11
-rw-r--r--ctrack/organisations/tests/test_views.py10
-rw-r--r--ctrack/register/forms.py6
-rw-r--r--ctrack/register/tests/test_views.py2
5 files changed, 35 insertions, 7 deletions
diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py
index c8340b9..330ad79 100644
--- a/ctrack/organisations/tests/factories.py
+++ b/ctrack/organisations/tests/factories.py
@@ -7,6 +7,7 @@ from factory import Faker, SubFactory, post_generation
from factory.django import DjangoModelFactory
from ctrack.organisations.models import Address, Organisation, Person, Role
+from ctrack.register.models import SingleDateTimeEvent
from ctrack.users.tests.factories import UserFactory
User = get_user_model()
@@ -119,3 +120,15 @@ class AddressFactory(DjangoModelFactory):
class Meta:
model = Address
+
+
+class SingleDateTimeEventFactory(DjangoModelFactory):
+ type_descriptor = None # must pass this in
+ short_description = "Nothing short description"
+ datetime = "2020-02-10 10:00"
+ comments = "Nothing comments"
+ location = "Gark's basin"
+ user = SubFactory(UserFactory)
+
+ class Meta:
+ model = SingleDateTimeEvent
diff --git a/ctrack/organisations/tests/test_factories.py b/ctrack/organisations/tests/test_factories.py
index 227d7db..0b793c3 100644
--- a/ctrack/organisations/tests/test_factories.py
+++ b/ctrack/organisations/tests/test_factories.py
@@ -1,9 +1,13 @@
+import pytest
+
from ctrack.organisations.tests.factories import (
OrganisationFactory,
PersonFactory,
- RoleFactory,
+ RoleFactory, SingleDateTimeEventFactory,
)
+pytestmark = pytest.mark.django_db
+
def test_organisation_factory():
o = OrganisationFactory.build()
@@ -19,3 +23,8 @@ def test_person_factory():
r = RoleFactory.build()
p = PersonFactory.build(role=r, predecessor__predecessor=None)
assert p.first_name
+
+
+def test_meeting_event_factory():
+ meeting = SingleDateTimeEventFactory.create(type_descriptor="MEETING")
+ assert meeting.type_descriptor == "MEETING"
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index 85ccc5a..6ae9ff8 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -5,8 +5,7 @@ from django.test import RequestFactory
from django.urls import reverse
from ctrack.caf.tests.factories import PersonFactory
-from ctrack.organisations.models import Mode, Submode
-from ctrack.organisations.tests.factories import OrganisationFactory, RoleFactory
+from ctrack.organisations.tests.factories import OrganisationFactory
from ctrack.organisations.views import IncidentReportCreateView
from ..views import OrganisationListView
@@ -14,9 +13,13 @@ from ..views import OrganisationListView
pytestmark = pytest.mark.django_db
+# TODO - come back to this
+def test_meetings_in_organisation_detail_view(user, client):
+ pass
+
+
# https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#example
def test_organisation_list_view():
-
OrganisationFactory.create()
OrganisationFactory.create()
OrganisationFactory.create()
@@ -39,7 +42,6 @@ def test_organisation_list_view():
def test_only_member_of_cct_user_group_can_view_org_list():
-
OrganisationFactory.create()
OrganisationFactory.create()
OrganisationFactory.create()
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py
index b061ec3..39900e6 100644
--- a/ctrack/register/forms.py
+++ b/ctrack/register/forms.py
@@ -33,9 +33,13 @@ class CreateSimpleDateTimeEventForm(forms.ModelForm):
]
def __init__(self, *args, **kwargs):
+ self.event_type = None
self.user = kwargs.pop("user")
self.org_slug = kwargs.pop("org_slug")
- self.event_type = kwargs.pop("event_type")
+ try:
+ self.event_type = kwargs.pop("event_type")
+ except KeyError:
+ pass
super().__init__(*args, **kwargs)
if self.org_slug:
org = Organisation.objects.get(slug=self.org_slug)
diff --git a/ctrack/register/tests/test_views.py b/ctrack/register/tests/test_views.py
index 0f5575d..306cec5 100644
--- a/ctrack/register/tests/test_views.py
+++ b/ctrack/register/tests/test_views.py
@@ -122,7 +122,7 @@ class TestSingleDateTimeEvent:
response = client.get(url)
html = response.content.decode("utf-8")
assert response.status_code == 200
- test_case.assertInHTML("Create a new simple event", html)
+ test_case.assertInHTML(f"Create a new simple event involving {org.name}", html)
def test_org_passed_as_kwarg(self, user, org, request_factory):
slug = org.slug