diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-24 16:35:44 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-24 16:35:44 +0100 |
commit | 54aa9bfe8a3815229b5b79f28a4fcc9e0e32fdbc (patch) | |
tree | 0d82afb16d37c78a90257bb53b03e2c321c584db | |
parent | 84e5076fa235be060f99f38dec59ddd0f9ca4dbc (diff) |
working on test_profile_view_contains_organisation_information - FAILING
Diffstat (limited to '')
-rw-r--r-- | ctrack/users/tests/test_views.py | 16 | ||||
-rw-r--r-- | ctrack/users/views.py | 4 |
2 files changed, 17 insertions, 3 deletions
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index 3e7fbf7..33ab238 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -2,7 +2,7 @@ import pytest from django.test import RequestFactory from ctrack.users.models import User -from ctrack.users.views import UserRedirectView, UserUpdateView +from ctrack.users.views import UserDetailView, UserRedirectView, UserUpdateView pytestmark = pytest.mark.django_db @@ -44,3 +44,17 @@ class TestUserRedirectView: view.request = request assert view.get_redirect_url() == f"/users/{user.username}/" + + +def test_profile_view_contains_organisation_information(user: User): + """url: users/username + This is where users are redirected to when they log in and where I want to capture + information about the user - particularly if they are an OES user. + """ + factory = RequestFactory() + request = factory.get(f"/users/{user.username}") + # we have to do the following to simulate logged-in user + # Django Advanced Testing Topics + request.user = user + response = UserDetailView.as_view()(request) + assert response.status_code == 300 diff --git a/ctrack/users/views.py b/ctrack/users/views.py index 9cf69e9..a292191 100644 --- a/ctrack/users/views.py +++ b/ctrack/users/views.py @@ -1,9 +1,9 @@ +from django.contrib import messages from django.contrib.auth import get_user_model from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse -from django.views.generic import DetailView, RedirectView, UpdateView -from django.contrib import messages from django.utils.translation import ugettext_lazy as _ +from django.views.generic import DetailView, RedirectView, UpdateView User = get_user_model() |