diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-10-18 16:33:07 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-10-18 16:33:07 +0100 |
commit | dbc2cf0662323abadd08b0d7eb6746905466017d (patch) | |
tree | 0161f6a0d23e145806086b3ad964d9f0416582a9 /ctrack/organisations/tests | |
parent | d6a3d976e0a7bd2bde93a5ea5543e9e68922520d (diff) |
basic inclusion of single datetime events in org detail page - no formatting and passing tests
Diffstat (limited to 'ctrack/organisations/tests')
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 9 | ||||
-rw-r--r-- | ctrack/organisations/tests/test_views.py | 32 |
2 files changed, 36 insertions, 5 deletions
diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index e4caeb5..141f518 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -7,7 +7,7 @@ from ctrack.caf.models import CAF, Grading from ctrack.caf.models import EssentialService from ctrack.caf.tests.factories import ApplicableSystemFactory from ctrack.core.utils import fnames -from ctrack.organisations.tests.factories import PersonFactory +from ctrack.organisations.tests.factories import PersonFactory, SingleDateTimeEventFactory pytestmark = pytest.mark.django_db @@ -28,6 +28,13 @@ def test_organisation_get_absolute_url(org): assert org.get_absolute_url() == f"/organisations/{slug}/" +def test_can_get_all_single_datetime_events_involving_person(person): + e = SingleDateTimeEventFactory.create(type_descriptor="MEETING", short_description="No desc") + e.participants.add(person) + events_involving_person = person.get_single_datetime_events() + assert events_involving_person.first().short_description == "No desc" + + def test_update_organisation(org_with_people): # Change the name of the organisation org_with_people.name = "Tonkers Ltd" diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py index 6ae9ff8..dbd717f 100644 --- a/ctrack/organisations/tests/test_views.py +++ b/ctrack/organisations/tests/test_views.py @@ -5,7 +5,10 @@ from django.test import RequestFactory from django.urls import reverse from ctrack.caf.tests.factories import PersonFactory -from ctrack.organisations.tests.factories import OrganisationFactory +from ctrack.organisations.tests.factories import ( + OrganisationFactory, + SingleDateTimeEventFactory, +) from ctrack.organisations.views import IncidentReportCreateView from ..views import OrganisationListView @@ -13,9 +16,30 @@ from ..views import OrganisationListView pytestmark = pytest.mark.django_db -# TODO - come back to this -def test_meetings_in_organisation_detail_view(user, client): - pass +def test_meetings_in_organisation_detail_view(user, client, org_with_people): + org_list_permission = Permission.objects.get(name="Can view organisation") + assert user.user_permissions.count() == 0 + user.user_permissions.add(org_list_permission) + assert user.has_perm("organisations.view_organisation") + user.save() + person = org_with_people.person_set.first() + e1 = SingleDateTimeEventFactory.create( + type_descriptor="MEETING", short_description="First Meeting" + ) + e2 = SingleDateTimeEventFactory.create( + type_descriptor="MEETING", short_description="Second Meeting" + ) + e1.participants.add(person) + e1.save() + e2.participants.add(person) + e2.save() + client.force_login(user) + response = client.get( + reverse("organisations:detail", kwargs={"slug": org_with_people.slug}) + ) + assert response.status_code == 200 + html = response.content.decode("utf-8") + assert "First Meeting" in html # https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#example |