Horizon provides several useful base classes for testing both views and API functions.
Specialized base test case class for Horizon which 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.
Asserts that the response does contain a form in it’s context, and that form has errors, if count were given, it must match the exact numbers of errors
Asserts that the specified number of messages have been attached for various message types. Usage would look like self.assertMessageCount(success=1).
Asserts that the response either does not contain a form in it’s context, or that if it does, that form has no errors.
Asserts that no messages have been attached by the contrib.messages framework.