Common API¶
Main interface¶
Main package file for pytroll watchers.
Testing utilities¶
Pytest fixtures and utilities for testing code that uses pytroll watchers.
- pytroll_watchers.testing.load_oauth_responses(*responses_to_load, response_file=None)¶
Load the oauth responses for mocking the requests to copernicus dataspace.
- Parameters:
responses_to_load – The responses to load.
response_file – The file where the responses are stored. Defaults to tests/dataspace_responses.yaml
Example
To get fake response for the watcher and test the generator, one could use:
with load_oauth_responses("token", "filtered_yesterday"): files = list(file_generator(filter_string, check_interval, timedelta(hours=24)))
- pytroll_watchers.testing.patched_bucket_listener(monkeypatch)¶
Patch the records produced by the underlying bucket listener.
Example
This context manager can be used like this:
>>> with patched_bucket_listener(records_to_produce): ... for record in bucket_notification_watcher.file_generator(endpoint, bucket): ... # do something with the record
- pytroll_watchers.testing.patched_local_events(monkeypatch)¶
Patch the events produced by underlying os/polling watcher.
Example
The produced context managed can be used like this:
>>> with patched_local_events(["/tmp/file1", "/tmp/file2"]): ... assert "/tmp/file1" in local_watcher.file_generator("/tmp")