def test_gcs_writes_binary_string(self, google_client): blob = MagicMock() google_client.return_value.bucket = MagicMock(return_value=MagicMock( blob=MagicMock(return_value=blob))) handler = GCSResultHandler(bucket="foo") handler.write(None) assert blob.upload_from_string.called assert isinstance(blob.upload_from_string.call_args[0][0], str)
def test_gcs_writes_to_blob_prefixed_by_date_suffixed_by_prefect( self, google_client): bucket = MagicMock() google_client.return_value.bucket = MagicMock(return_value=bucket) handler = GCSResultHandler(bucket="foo") handler.write("so-much-data") assert bucket.blob.called assert bucket.blob.call_args[0][0].startswith( pendulum.now("utc").format("Y/M/D")) assert bucket.blob.call_args[0][0].endswith("prefect_result")