githubapp.test_helper.test_case
Class to help apps to create testing emulating webhooks events
Module Contents
Classes
Class to help apps to create testing emulating webhooks events |
Functions
Edit the object’s attributes using the provided attributes. |
|
Mock the reading of the config file |
|
Recursively updates the main_dict with the given updates. |
Data
API
- githubapp.test_helper.test_case.T
‘TypeVar(…)’
- class githubapp.test_helper.test_case.TestCase(*args, **kwargs)
Bases:
unittest.TestCaseClass to help apps to create testing emulating webhooks events
Initialization
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- assert_check_run_final_state(name: str, title: str = None, summary: str = None, status: githubapp.event_check_run.CheckRunStatus = None, conclusion: githubapp.event_check_run.CheckRunConclusion = None) None
Asserts that the final state of a check run matches the given parameters.
:param name: The name of the check run to check. :param title: (optional) The expected title of the check run output. :param summary: (optional) The expected summary of the check run output. :param status: (optional) The expected status of the check run. :param conclusion: (optional) The expected conclusion of the check run. :return: None
- assert_check_run_progression(name: str, calls: list[unittest.mock.call]) None
Asserts the progression of check runs for a given name and list of calls.
:param name: The name of the check run. :param calls: The list of calls to be made to the check run. :return: None :raise AssertionError: If there are no check runs, or if there is no check run with the given name, or if there are missing calls.
- assert_check_run_start(name: str, **kwargs) None
Asserts that a check run with the given name has been started.
- assert_no_check_run(name: str) None
Asserts that no check run exists with the given name. :raise AssertionError: If there are a check runs with given name
- assert_sub_run_call(check_run_name: str, sub_run_name: str, **params) None
- static create_github_exception(message: str, status: int = 500) github.GithubException
Simple way to create a GithubException for tests
return a GithubException(STATUS, data={“errors”: [{“message”: MESSAGE}]})
- create_sub_runs(check_run_name: str, *sub_run_names: str) None
Create sub runs for a given check run.
- deliver(event_type: type[githubapp.events.event.Event], **params) Optional[githubapp.events.event.Event]
This method delivers an event of the specified type with the given parameters. It creates an event instance, updates the parameters, and then posts the event to the client.
The
event_typeparameter defines the type of event to deliver. It should be a subclass ofEvent.The
paramsparameter is a dictionary containing additional parameters to include in the event. If a parameter is not present inparams, the default value will be used.The method uses a patch context to mock certain dependencies and headers for testing purposes. If the response status code is not a successful 2XX code, an AssertionError is raised with information about the error.
- get_check_run(name: str) githubapp.EventCheckRun
Get a Check Run by its name.
- get_filename() Optional[str]
Returns the filename for the test.
- get_info_from_file(filename: str = None) dict[str, Any]
Retrieve information from a json file.
- static sub_run_call(name: str, title: str, summary: str = '') unittest.mock.call
- githubapp.test_helper.test_case.edit(self: github.CheckRun.CheckRun, **attributes) None
Edit the object’s attributes using the provided attributes.
- githubapp.test_helper.test_case.get_config(*_args, **_kwargs) unittest.mock.Mock
Mock the reading of the config file
- githubapp.test_helper.test_case.recursive_update(main_dict: dict[str, Any], updates: dict[str, Any]) None
Recursively updates the main_dict with the given updates.
:param main_dict: The dictionary to be updated. :param updates: The dictionary with the updates to be applied. :return: None.