Ask Your Question

How to test HTML response from Horizon?

asked 2015-01-05 19:33:41 -0500

dpar gravatar image

Hello, I'd like to test HTML response from Horizon using the openstack_dashboard.test.helpers.TestCase

Whenever I run a simple test case though (getting HTML for /auth/login), I get a 404. Here is my code:

import testtools
import uuid
from django import http
from django.test import Client
from django.test import TestCase
from django.test import RequestFactory
from django import conf

import horizon
from importlib import import_module
from openstack_dashboard.test import helpers as test
from horizon import base
from openstack_dashboard import api
from openstack_dashboard.usage import base as usage_base
from openstack_dashboard.api import cinder

class Test(test.TestCase):

    def setUp(self):
        super(Test, self).setUp()

    def test_base(self):
        response = self.client.get('/auth/login')
        self.assertEqual(response.content,  ' ')

Any ideas what is going wrong? TY

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-06 07:01:37 -0500

jpichon gravatar image

updated 2015-01-06 07:02:17 -0500

I get a status code of 301 as expected when running this test (because the URL redirects to /auth/login/, with the final slash). Because of this there is no content at all (so your test would pass with '' rather than ' ') on the last line.

If you're curious to see the content of a response, you can print the response variable before testing for anything, and it shows you the content as well as a few headers. Hope this helps!

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-01-05 19:33:41 -0500

Seen: 86 times

Last updated: Jan 06 '15