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 clear_all_except(bucket, keys)[source]

Removes all objects from the passed ‘bucket’ except those whose keys are or start with any key in ‘keys’

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)[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_object(bucket, key)[source]

Removes the object at ‘key’

static delete_par(bucket, par)[source]

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

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

Returns the names of all objects in the passed bucket

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

Return all of the objects in the passed bucket

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

Return all of the json objects in the passed bucket as json-deserialised objects

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

Return all of the strings 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_object(bucket, key)[source]

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

static get_object_as_file(bucket, key, filename)[source]

Get the object contained in the key ‘key’ in the passed ‘bucket’ and writing this to the file called ‘filename’

static get_object_from_json(bucket, key)[source]

Return an object constructed from json stored at ‘key’ in the passed bucket. This returns None if there is no data at this key

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 get_string_object(bucket, key)[source]

Return the string in ‘bucket’ associated with ‘key’

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

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

static set_object_from_file(bucket, key, filename)[source]

Set the value of ‘key’ in ‘bucket’ to equal the contents of the file located by ‘filename’

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

Set the value of ‘key’ in ‘bucket’ to equal to contents of ‘data’, which has been encoded to json

static set_string_object(bucket, key, string_data)[source]

Set the value of ‘key’ in ‘bucket’ to the string ‘string_data’