augustjd / flask-warehouse Goto Github PK
View Code? Open in Web Editor NEWConnect your Flask app to S3, Alicloud, or Heroku, with a clean common interface.
License: MIT License
Connect your Flask app to S3, Alicloud, or Heroku, with a clean common interface.
License: MIT License
Cubby content/attribute updates overwrite metadata
Here's a test case to highlight that behaviour
@mock_s3
def test_s3_service_metadata_preservation(app):
"""Sample pytest test function with the pytest fixture as an argument.
"""
app.config['WAREHOUSE_DEFAULT_SERVICE'] = 's3'
app.config['WAREHOUSE_DEFAULT_LOCATION'] = 'us-west-1'
warehouse = Warehouse(app)
assert warehouse.service is not None
assert warehouse.service.id == 's3'
with app.app_context():
cubby = warehouse('s3:///something/beautiful')
cubby.store(bytes=b'12345')
# setting meta data works
assert cubby.metadata() == {}
metadata = {"tag": "value"}
assert cubby.set_metadata(metadata)
assert cubby.metadata() == metadata
# setting mimetype works
assert cubby.mimetype() == None
cubby.set_mimetype("application/octet-stream")
assert cubby.mimetype() == 'application/octet-stream'
# this fails, setting mimetype actually overwrites metadata
assert cubby.metadata() == metadata
The last check raises the following exception:
> assert cubby.metadata() == metadata
E AssertionError: assert {} == {'tag': 'value'}
E Right contains more items:
E {'tag': 'value'}
E Full diff:
E - {}
E + {'tag': 'value'}
if we replace cubby.set_metadata
with a content update, the test fails at the same point as well:
@mock_s3
def test_s3_service_metadata_preservation(app):
"""Sample pytest test function with the pytest fixture as an argument.
"""
app.config['WAREHOUSE_DEFAULT_SERVICE'] = 's3'
app.config['WAREHOUSE_DEFAULT_LOCATION'] = 'us-west-1'
warehouse = Warehouse(app)
assert warehouse.service is not None
assert warehouse.service.id == 's3'
with app.app_context():
cubby = warehouse('s3:///something/beautiful')
cubby.store(bytes=b'12345')
# setting meta data works
assert cubby.metadata() == {}
metadata = {"tag": "value"}
assert cubby.set_metadata(metadata)
assert cubby.metadata() == metadata
# setting mimetype works
cubby.store(bytes=b'123456')
assert cubby.retrieve() == b'123456'
# this fails, setting mimetype actually overwrites metadata
assert cubby.metadata() == metadata
I think it would be tedious to explicitly pass in each property of the copy along with each request, perhaps the ExtraArgs
should be built for all requests using a custom property, and the it's updated explicilty inside each set_*
function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.