Acquire.ObjectStore._testing_objstore module

class Testing_ObjectStore[source]

Bases: object

This is a dummy object store that writes objects to the standard posix filesystem when running tests

static close_par(par=None, par_uid=None, url_checksum=None)[source]

Close the passed PAR, which provides access to data in the passed bucket

static create_bucket(bucket, bucket_name, compartment=None)[source]

Create and return a new bucket in the object store called ‘bucket_name’, optionally placing it into the compartment identified by ‘compartment’. This will raise an ObjectStoreError if this bucket already exists

static create_par(bucket, encrypt_key, key=None, readable=True, writeable=False, duration=3600, cleanup_function=None)[source]

Create a pre-authenticated request for the passed bucket and key (if key is None then the request is for the entire bucket). This will return a PAR object that will contain a URL that can be used to access the object/bucket. If writeable is true, then the URL will also allow the object/bucket to be written to. PARs are time-limited. Set the lifetime in seconds by passing in ‘duration’ (by default this is one hour). Note that you must pass in a public key that will be used to encrypt this PAR. This is necessary as the PAR grants access to anyone who can decrypt the URL

static delete_all_objects(bucket, prefix=None)[source]

Deletes all objects…

static delete_bucket(bucket, force=False)[source]

Delete the passed bucket. This should be used with caution. Normally you can only delete a bucket if it is empty. If ‘force’ is True then it will remove all objects/pars from the bucket first, and then delete the bucket. This can cause a LOSS OF DATA!

static delete_object(bucket, key)[source]

Removes the object at ‘key’

static get_all_object_names(bucket, prefix=None)[source]

Returns the names of all objects in the passed bucket

static get_bucket(bucket, bucket_name, compartment=None, create_if_needed=True)[source]

Find and return a new bucket in the object store called ‘bucket_name’, optionally placing it into the compartment identified by ‘compartment’. If ‘create_if_needed’ is True then the bucket will be created if it doesn’t exist. Otherwise, if the bucket does not exist then an exception will be raised.

static get_bucket_name(bucket)[source]

Return the name of the passed bucket

static get_object(bucket, key)[source]

Return the binary data contained in the key ‘key’ in the passed bucket

static get_size_and_checksum(bucket, key)[source]

Return the object size (in bytes) and checksum of the object in the passed bucket at the specified key

static is_bucket_empty(bucket)[source]

Return whether or not the passed bucket is empty

static set_object(bucket, key, data)[source]

Set the value of ‘key’ in ‘bucket’ to binary ‘data’

static take_object(bucket, key)[source]

Take (delete) the object from the object store, returning the object