Horizon provides a base test case class which provides several useful pre-prepared attributes for testing Horizon components.
horizon.test.helpers.
TestCase
(methodName='runTest')[source]¶Base test case class for Horizon with numerous additional features.
mox
mocking framework via self.mox
if use_mox
attribute is set to True.
Note that use_mox
defaults to False.RequestFactory
class which supports Django’s contrib.messages
framework via self.factory
.self.request
.assertMessageCount
(response=None, **kwargs)[source]¶Asserts that the expected number of messages have been attached.
The expected number of messages can be specified per message type.
Usage would look like self.assertMessageCount(success=1)
.
The OpenStack Dashboard also provides test case classes for greater ease-of-use when testing APIs and OpenStack-specific auth scenarios.
openstack_dashboard.test.helpers.
TestCase
(methodName='runTest')[source]¶Specialized base test case class for Horizon.
It gives access to numerous additional features:
self.servers
, self.user
, etc.). See the
docs for
TestData
for more information.mox
mocking framework via self.mox
.
if use_mox
attribute is set to True.self.context
.RequestFactory
class which supports Django’s contrib.messages
framework via self.factory
.self.request
.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.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.