aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-30 09:33:29 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-30 09:33:29 +0100
commit9307fc7676db68de4b3d25f795aa2a351f9d4843 (patch)
tree61ca1e81e49837707e1c725af1ebbe395493b0cd /ctrack/organisations
parent3aec120ae42cb29049c8ba3d8d52d2388e56bb36 (diff)
cleaned up tests
Diffstat (limited to 'ctrack/organisations')
-rw-r--r--ctrack/organisations/tests/conftest.py5
-rw-r--r--ctrack/organisations/tests/test_forms.py45
-rw-r--r--ctrack/organisations/tests/test_views.py14
3 files changed, 35 insertions, 29 deletions
diff --git a/ctrack/organisations/tests/conftest.py b/ctrack/organisations/tests/conftest.py
index ce72835..85fa2eb 100644
--- a/ctrack/organisations/tests/conftest.py
+++ b/ctrack/organisations/tests/conftest.py
@@ -11,11 +11,6 @@ from ctrack.organisations.tests.factories import (
@pytest.fixture
-def full_db_fixture():
- populate_db(orgs=2, igps=2)
-
-
-@pytest.fixture
def role():
return RoleFactory.create(name="Test Role")
diff --git a/ctrack/organisations/tests/test_forms.py b/ctrack/organisations/tests/test_forms.py
index b742d10..322c856 100644
--- a/ctrack/organisations/tests/test_forms.py
+++ b/ctrack/organisations/tests/test_forms.py
@@ -10,33 +10,40 @@ pytestmark = pytest.mark.django_db
# is instructive
# Can the form accept an org_id? We need this.
-def test_add_new_address_for_organisation_form(org):
- AddressCreateForm(org=org)
+@pytest.mark.skip("Explore how the inline form address addresses to an organisation")
+def test_add_new_address_for_organisation_form(org_with_people):
+ AddressCreateForm(org=org_with_people)
# Will our form raise an exception if the org_id isn't specified?
-def test_add_new_address_init_without_org_id(org):
+@pytest.mark.skip("Explore how the inline form address addresses to an organisation")
+def test_add_new_address_init_without_org_id(org_with_people):
with pytest.raises(KeyError):
AddressCreateForm()
-def test_add_new_address_with_valid_data(org):
+@pytest.mark.skip("Explore how the inline form address addresses to an organisation")
+def test_add_new_address_with_valid_data(org_with_people):
at = AddressType.objects.create(descriptor="Primary Address").pk
- form = AddressCreateForm({
- "type": at,
- "line1": "10 Bawbags Lane",
- "line2": "Awful Area",
- "line3": "Chudleigh Meadows",
- "city": "Curstan",
- "county": "East Suncto",
- "postcode": "ET31 3PF",
- "country": "UK",
- "other_details": "There is nothing great about this place!",
- }, org=org)
-
-
-def test_add_new_address_blank_data(org):
- form = AddressCreateForm({}, org=org)
+ form = AddressCreateForm(
+ {
+ "type": at,
+ "line1": "10 Bawbags Lane",
+ "line2": "Awful Area",
+ "line3": "Chudleigh Meadows",
+ "city": "Curstan",
+ "county": "East Suncto",
+ "postcode": "ET31 3PF",
+ "country": "UK",
+ "other_details": "There is nothing great about this place!",
+ },
+ org=org_with_people,
+ )
+
+
+@pytest.mark.skip("Explore how the inline form address addresses to an organisation")
+def test_add_new_address_blank_data(org_with_people):
+ form = AddressCreateForm({}, org=org_with_people)
assert not form.is_valid()
assert form.errors == {
"type": ["This field is required."],
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index cebcda9..8e8fff7 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -1,5 +1,6 @@
import pytest
from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Permission
from django.test import RequestFactory
from ctrack.organisations.tests.factories import OrganisationFactory
@@ -21,6 +22,12 @@ def test_organisation_list_view():
user = get_user_model().objects.create_user(
username="testy", email="testy@test.com", password="test1020"
)
+ # This user needs permission to acccess the list view
+ 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()
request = factory.get("/organisations")
request.user = user
response = OrganisationListView.as_view()(request)
@@ -28,13 +35,10 @@ def test_organisation_list_view():
assert len(response.context_data["organisation_list"]) == 3
-def test_incident_report_create_view():
- user = get_user_model().objects.create_user(
- username="testy", email="testy@test.com", password="test1020"
- )
+def test_incident_report_create_view(stakeholder_user):
org = OrganisationFactory.create()
factory = RequestFactory()
request = factory.get(f"{org.name}/create-incident-report")
- request.user = user
+ request.user = stakeholder_user
response = IncidentReportCreateView.as_view()(request, org.slug)
assert response.status_code == 200