1.22. testing
¶
This module provides supporting functionality for the included application unit tests.
1.22.1. Data¶
-
TEST_MESSAGE_TEMPLATE
[source]¶ A string representing a message template that can be used for testing.
-
TEST_MESSAGE_TEMPLATE_INLINE_IMAGE
[source]¶ A string with the path to a file used as an inline image in the
TEST_MESSAGE_TEMPLATE
.
1.22.2. Classes¶
-
class
KingPhisherTestCase
(*args, **kwargs)[source]¶ Bases:
smoke_zephyr.utilities.TestCase
This class provides additional functionality over the built in
unittest.TestCase
object, including better compatibility for methods across Python 2.x and Python 3.x.-
assertIsSubclass
(obj, cls, msg=None)[source]¶ Test that obj is a subclass of cls (which can be a class or a tuple of classes as supported by
issubclass()
).
-
-
class
KingPhisherServerTestCase
(*args, **kwargs)[source]¶ Bases:
king_phisher.testing.KingPhisherTestCase
This class can be inherited to automatically set up a King Phisher server instance configured in a way to be suitable for testing purposes.
-
assertHTTPStatus
(http_response, status)[source]¶ Check an HTTP response to ensure that the correct HTTP status code is specified.
Parameters: - http_response (
httplib.HTTPResponse
) – The response object to check. - status (int) – The status to check for.
- http_response (
-
assertRPCPermissionDenied
(method, *args, **kwargs)[source]¶ Assert that the specified RPC method fails with a
KingPhisherPermissionError
exception.Parameters: method – The RPC method that is to be tested
-
http_request
(resource, method='GET', include_id=True, body=None, headers=None)[source]¶ Make an HTTP request to the specified resource on the test server.
Parameters: Returns: The servers HTTP response.
Return type: httplib.HTTPResponse
-
web_root_files
(limit=None, include_templates=True)[source]¶ A generator object that yields valid files which are contained in the web root of the test server instance. This can be used to find resources which the server should process as files. The function will fail if no files can be found in the web root.
Parameters:
-