[ English | 中文 (简体, 中国) | русский | português (Brasil) | नेपाली | 한국어 (대한민국) | Indonesia | français | español | esperanto | English (United Kingdom) | Deutsch ]
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')[исходный код]¶
Base test case class for Horizon with numerous additional features.
A
RequestFactoryclass which supports Django’scontrib.messagesframework viaself.factory.A ready-to-go request object via
self.request.
- assertMessageCount(response=None, **kwargs)[исходный код]¶
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).
- assertNoMessages(response=None)[исходный код]¶
Asserts no messages have been attached by the messages framework.
The expected messages framework is
django.contrib.messages.
- setUp()[исходный код]¶
Hook method for setting up the test fixture before exercising it.
- tearDown()[исходный код]¶
Hook method for deconstructing the test fixture after testing it.
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')[исходный код]¶
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 forTestDatafor more information.A set of request context data via
self.context.A
RequestFactoryclass which supports Django’scontrib.messagesframework viaself.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.
- assertFormErrors(response, count=0, message=None, context_name='form')[исходный код]¶
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')[исходный код]¶
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.
- assertNoWorkflowErrors(response, context_name='workflow')[исходный код]¶
Checks for no workflow errors.
Asserts that the response either does not contain a workflow in its context, or that if it does, that workflow has no errors.
- assertRedirectsNoFollow(response, expected_url)[исходный код]¶
Check for redirect.
Asserts that the given response issued a 302 redirect without processing the view which is redirected to.
- assertStatusCode(response, expected_code)[исходный код]¶
Validates an expected status code.
Matches camel case of other assert functions
- assertWorkflowErrors(response, count=0, message=None, context_name='workflow')[исходный код]¶
Check for workflow errors.
Asserts that the response does contain a workflow in its context, and that workflow has errors, if count were given, it must match the exact numbers of errors
- setUp()[исходный код]¶
Hook method for setting up the test fixture before exercising it.
- tearDown()[исходный код]¶
Hook method for deconstructing the test fixture after testing it.
- class openstack_dashboard.test.helpers.APITestCase(methodName='runTest')[исходный код]¶
- setUp()[исходный код]¶
Hook method for setting up the test fixture before exercising it.
- class openstack_dashboard.test.helpers.BaseAdminViewTests(methodName='runTest')[исходный код]¶
Sets an active user with the «admin» role.
For testing admin-only views and functionality.