diff options
author | MR Lemon <matt@matthewlemon> | 2020-05-14 17:10:04 +0100 |
---|---|---|
committer | MR Lemon <matt@matthewlemon> | 2020-05-14 17:10:04 +0100 |
commit | 738ec0ee2d06ccaeaff031d4d3350d4319b010f9 (patch) | |
tree | a25dad748d69e32abaebca36be7261799c0989f9 /ctrack/organisations/tests/test_views.py | |
parent | 729fd76ed2da6c23e7f8ece264e3b8458b133fe6 (diff) |
how to do a raw CBV test - and not pretty...
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/tests/test_views.py | 20 |
1 files changed, 20 insertions, 0 deletions
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 |