b2sdk.raw_simulator
– B2 raw api simulator¶
-
b2sdk.raw_simulator.
get_bytes_range
(data_bytes, bytes_range)[source]¶ Slice bytes array using bytes range
-
class
b2sdk.raw_simulator.
KeySimulator
(account_id, name, application_key_id, key, capabilities, expiration_timestamp_or_none, bucket_id_or_none, bucket_name_or_none, name_prefix_or_none)[source]¶ Bases:
object
Hold information about one application key, which can be either a master application key, or one created with create_key().
-
__init__
(account_id, name, application_key_id, key, capabilities, expiration_timestamp_or_none, bucket_id_or_none, bucket_name_or_none, name_prefix_or_none)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
b2sdk.raw_simulator.
PartSimulator
(file_id, part_number, content_length, content_sha1, part_data)[source]¶ Bases:
object
-
class
b2sdk.raw_simulator.
FileSimulator
(account_id, bucket_id, file_id, action, name, content_type, content_sha1, file_info, data_bytes, upload_timestamp, range_=None)[source]¶ Bases:
object
One of three: an unfinished large file, a finished file, or a deletion marker.
-
__init__
(account_id, bucket_id, file_id, action, name, content_type, content_sha1, file_info, data_bytes, upload_timestamp, range_=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
b2sdk.raw_simulator.
FakeRequest
(url, headers)¶ Bases:
tuple
-
headers
¶ Alias for field number 1
-
url
¶ Alias for field number 0
-
-
class
b2sdk.raw_simulator.
FakeResponse
(file_sim, url, range_=None)[source]¶ Bases:
object
-
__init__
(file_sim, url, range_=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
request
¶
-
-
class
b2sdk.raw_simulator.
BucketSimulator
(account_id, bucket_id, bucket_name, bucket_type, bucket_info=None, cors_rules=None, lifecycle_rules=None, options_set=None)[source]¶ Bases:
object
-
FIRST_FILE_NUMBER
= 9999¶
-
FIRST_FILE_ID
= '9999'¶
-
FILE_SIMULATOR_CLASS
¶ alias of
b2sdk.raw_simulator.FileSimulator
-
RESPONSE_CLASS
¶ alias of
b2sdk.raw_simulator.FakeResponse
-
__init__
(account_id, bucket_id, bucket_name, bucket_type, bucket_info=None, cors_rules=None, lifecycle_rules=None, options_set=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
copy_file
(file_id, new_file_name, bytes_range=None, metadata_directive=None, content_type=None, file_info=None, destination_bucket_id=None)[source]¶
-
list_file_versions
(start_file_name=None, start_file_id=None, max_file_count=None, prefix=None)[source]¶
-
update_bucket
(bucket_type=None, bucket_info=None, cors_rules=None, lifecycle_rules=None, if_revision_is=None)[source]¶
-
-
class
b2sdk.raw_simulator.
RawSimulator
[source]¶ Bases:
b2sdk.raw_api.AbstractRawApi
Implement the same interface as B2RawApi by simulating all of the calls and keeping state in memory.
The intended use for this class is for unit tests that test things built on top of B2RawApi.
-
BUCKET_SIMULATOR_CLASS
¶ alias of
b2sdk.raw_simulator.BucketSimulator
-
API_URL
= 'http://api.example.com'¶
-
DOWNLOAD_URL
= 'http://download.example.com'¶
-
MIN_PART_SIZE
= 200¶
-
MAX_DURATION_IN_SECONDS
= 86400000¶
-
UPLOAD_PART_MATCHER
= re.compile('https://upload.example.com/part/([^/]*)')¶
-
UPLOAD_URL_MATCHER
= re.compile('https://upload.example.com/([^/]*)/([^/]*)')¶
-
DOWNLOAD_URL_MATCHER
= re.compile('http://download.example.com(?:/b2api/v[0-9]+/b2_download_file_by_id\\?fileId=(?P<file_id>[^/]+)|/file/(?P<bucket_name>[^/]+)/(?P<file_name>.+))$')¶
-
expire_auth_token
(auth_token)[source]¶ Simulate the auth token expiring.
The next call that tries to use this auth token will get an auth_token_expired error.
-
set_upload_errors
(errors)[source]¶ Store a sequence of exceptions to raise on upload. Each one will be raised in turn, until they are all gone. Then the next upload will succeed.
-
create_bucket
(api_url, account_auth_token, account_id, bucket_name, bucket_type, bucket_info=None, cors_rules=None, lifecycle_rules=None)[source]¶
-
create_key
(api_url, account_auth_token, account_id, capabilities, key_name, valid_duration_seconds, bucket_id, name_prefix)[source]¶
-
copy_file
(api_url, account_auth_token, source_file_id, new_file_name, bytes_range=None, metadata_directive=None, content_type=None, file_info=None, destination_bucket_id=None)[source]¶
-
copy_part
(api_url, account_auth_token, source_file_id, large_file_id, part_number, bytes_range=None)[source]¶
-
list_file_names
(api_url, account_auth_token, bucket_id, start_file_name=None, max_file_count=None, prefix=None)[source]¶
-
list_file_versions
(api_url, account_auth_token, bucket_id, start_file_name=None, start_file_id=None, max_file_count=None, prefix=None)[source]¶
-
list_keys
(api_url, account_auth_token, account_id, max_key_count=1000, start_application_key_id=None)[source]¶
-
list_unfinished_large_files
(api_url, account_auth_token, bucket_id, start_file_id=None, max_file_count=None, prefix=None)[source]¶
-
start_large_file
(api_url, account_auth_token, bucket_id, file_name, content_type, file_info)[source]¶
-
update_bucket
(api_url, account_auth_token, account_id, bucket_id, bucket_type=None, bucket_info=None, cors_rules=None, lifecycle_rules=None, if_revision_is=None)[source]¶
-