PubSub unit testing helper functions and decorators (fixtures) into a PubSub test support library
Description
It would be useful to have generic functions and decorators (fixtures) that assist in unit testing publisher code
Further details
The Account Selector repo has a number of pytest fixtures that are useful for testing the publication of messages to PubSub. If these could be made generic it would assist in the implementation of PubSub in other areas and projects.
Task list
-
Create repository under uis/devops/libnameducam-pytest-pubsub-
Initialise with standard template (no boilerplate, but take example from ucam-faasor others in lib group).
-
-
Implement the fixtures from Account Selector in a generic form e.g. account_selector/tests/conftest.py/initial_topic -
Include helper functions e.g. account_selector/tests/utils.py/assert_events_received -
The fixtures rely on the PubSub emulator from Google being created as a container for testing. See Docker-compose.ymland the.gitlab-ci.ymlin Account Selector repo. This will need to be implemented, so instructions on how to do this need to be included.
Acceptance criteria
-
Able to import decorators/fixtures into conftest.pyand have them available to the testing files -
Able to import and use helper functions -
The instructions cover the setup of the PubSub emulator
Links/references
Edited by Mike Knee