FAQ | This is a LIVE service | Changelog

Skip to content

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/lib named ucam-pytest-pubsub
    • Initialise with standard template (no boilerplate, but take example from ucam-faas or 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.yml and the .gitlab-ci.yml in 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.py and 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

#17

Edited by Mike Knee