When stubbing out an S3 client, select_object_content gives me a ParamValidationError for "Payload".
The return value I'm attempting to use is structures as follows:
{
"Payload": [
{'Records': {'Payload': b'...'}},
...
]
}
The actual return value has that structure, except that the list is replaced with an EventStream of dicts, rather than a list of dicts. However, the following is specified in the error:
valid types: <class 'dict'>
How do I specify an EventStream (or other iterator) of the expected type if it only accepts a dict?
I had transcribed the structure incorrectly in the description. The description has now been fixed.
Seems to be an artifact of the fact that we're using the input validator, but on the output. EventStream can't be an input so it's not supported in the validator. This would be tricky to validate properly since fundamentally the event stream is a generic iterator so we can't simply consume any elements. We'd need to wrap it and validate things as they come out.
Is there a problem with consuming the iterator, and then re-wrapping it in an event stream?
This seems like a bug rather than an "enhancement". Is there a label other than enhancement that we can apply to this issue?
This is legit a bug. It's currently not possible to mock select_object_content with botocore. Here's a workaround with unittest.mock.