aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/organisations/tests')
-rw-r--r--ctrack/organisations/tests/conftest.py11
-rw-r--r--ctrack/organisations/tests/test_views.py20
2 files changed, 31 insertions, 0 deletions
diff --git a/ctrack/organisations/tests/conftest.py b/ctrack/organisations/tests/conftest.py
new file mode 100644
index 0000000..1435c86
--- /dev/null
+++ b/ctrack/organisations/tests/conftest.py
@@ -0,0 +1,11 @@
+
+# TODO Here we need to make use of the populate script to create a massive
+# test fixture.
+import pytest
+
+from ctrack.core.utils import populate_db
+
+
+@pytest.fixture
+def full_db_fixture():
+ populate_db(orgs=2, igps=2)
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
new file mode 100644
index 0000000..02d066a
--- /dev/null
+++ b/ctrack/organisations/tests/test_views.py
@@ -0,0 +1,20 @@
+import pytest
+from django.contrib.auth import get_user_model
+from django.test import RequestFactory
+
+from ..views import OrganisationListView
+
+pytestmark = pytest.mark.django_db
+
+
+# https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#example
+def test_organisation_list_view(full_db_fixture):
+ factory = RequestFactory()
+ user = get_user_model().objects.create_user(
+ username="testy", email="testy@test.com", password="test1020"
+ )
+ request = factory.get("/organisations")
+ request.user = user
+ response = OrganisationListView.as_view()(request)
+ assert response.status_code == 200
+ assert len(response.context_data["organisation_list"]) == 3