Horizon TestCase Classes

Horizon provides a base test case class which provides several useful pre-prepared attributes for testing Horizon components.

class horizon.test.helpers.TestCase(methodName='runTest')[source]

Specialized base test case class for Horizon which gives access to numerous additional features:

  • The mox mocking framework via self.mox.
  • A RequestFactory class which supports Django’s contrib.messages framework via self.factory.
  • A ready-to-go request object via self.request.
assertMessageCount(response=None, **kwargs)[source]

Asserts that the specified number of messages have been attached for various message types. Usage would look like self.assertMessageCount(success=1).

assertNoMessages(response=None)[source]

Asserts that no messages have been attached by the contrib.messages framework.

The OpenStack Dashboard also provides test case classes for greater ease-of-use when testing APIs and OpenStack-specific auth scenarios.

class openstack_dashboard.test.helpers.TestCase(methodName='runTest')[source]

Specialized base test case class for Horizon.

It gives access to numerous additional features:

  • A full suite of test data through various attached objects and managers (e.g. self.servers, self.user, etc.). See the docs for TestData for more information.
  • The mox mocking framework via self.mox.
  • A set of request context data via self.context.
  • A RequestFactory class which supports Django’s contrib.messages framework via self.factory.
  • A ready-to-go request object via self.request.
  • The ability to override specific time data controls for easier testing.
  • Several handy additional assertion methods.
add_panel_mocks()[source]

Global mocks on panels that get called on all views.

assertFormErrors(response, count=0, message=None, context_name='form')[source]

Check for form errors.

Asserts that the response does contain a form in its context, and that form has errors, if count were given, it must match the exact numbers of errors

assertNoFormErrors(response, context_name='form')[source]

Checks for no form errors.

Asserts that the response either does not contain a form in its context, or that if it does, that form has no errors.

assertRedirectsNoFollow(response, expected_url)[source]

Check for redirect.

Asserts that the given response issued a 302 redirect without processing the view which is redirected to.

assertStatusCode(response, expected_code)[source]

Validates an expected status code.

Matches camel case of other assert functions

class openstack_dashboard.test.helpers.APITestCase(methodName='runTest')[source]

Testing APIs.

For use with tests which deal with the underlying clients rather than stubbing out the openstack_dashboard.api.* methods.

class openstack_dashboard.test.helpers.BaseAdminViewTests(methodName='runTest')[source]

Sets an active user with the “admin” role.

For testing admin-only views and functionality.

Previous topic

Horizon Exceptions

Next topic

local.conf

Project Source

This Page