azure-quantum-python
azure-quantum-python copied to clipboard
Ability to enable and disable scrubbing of specific patterns in the test recordings
This PR adds the ability to enable and disable scrubbing of specific patterns in the test recordings.
Motivation
Disable the scrubbing of Storage Account SAS Key Expiration parameter se=
, so it can be recorded and we can add automated test of automatic refresh of the SAS Key.
We don't want to disable this scrubbing for all tests because then it would make all test recordings "expire" and fail as the SAS keys expire.
How to use it
- Import the
RegexScrubbingPatterns
class from the test'scommon
namespace.from common import RegexScrubbingPatterns
- Wrap the part of the code you want to temporarily disable a particular scrubbing rule
self.disable_scrubbing(RegexScrubbingPatterns.URL_QUERY_SAS_KEY_EXPIRATION) try: # your testing logic here that relies on the un-scrubbed value finally: self.enable_scrubbing(RegexScrubbingPatterns.URL_QUERY_SAS_KEY_EXPIRATION)