'Test that attempting to reach a course wiki page when not logged in
redirects the user to the login page'

@patch.dict('django.conf.settings.FEATURES', {'ALLOW_WIKI_ROOT_ACCESS': True})
def test_redirect_when_not_logged_in(self):

    self.logout()
    course_wiki_page = reverse('wiki:get', kwargs={'path': (self.toy.wiki_slug + '/')})
    resp = self.client.get(course_wiki_page, follow=False)
    self.assertEqual(resp.status_code, 302)
    resp = self.client.get(course_wiki_page, follow=True)
    (target_url, __) = resp.redirect_chain[(-1)]
    self.assertIn(reverse('signin_user'), target_url)
