1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
######################################################################
#
# File: test/unit/replication/conftest.py
#
# Copyright 2020 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from __future__ import annotations
import pytest
from apiver_deps import (
Bucket,
ReplicationConfiguration,
ReplicationMonitor,
ReplicationRule,
)
@pytest.fixture
def destination_bucket(b2api) -> Bucket:
return b2api.create_bucket('destination-bucket', 'allPublic')
@pytest.fixture
def source_bucket(b2api, destination_bucket) -> Bucket:
bucket = b2api.create_bucket('source-bucket', 'allPublic')
bucket.replication = ReplicationConfiguration(
rules=[
ReplicationRule(
destination_bucket_id=destination_bucket.id_,
name='name',
file_name_prefix='folder/',
),
],
source_key_id='hoho|trololo',
)
return bucket
@pytest.fixture
def test_file(tmpdir) -> str:
file = tmpdir.join('test.txt')
file.write('whatever')
return file
@pytest.fixture
def test_file_reversed(tmpdir) -> str:
file = tmpdir.join('test-reversed.txt')
file.write('revetahw')
return file
@pytest.fixture
def monitor(source_bucket) -> ReplicationMonitor:
return ReplicationMonitor(
source_bucket,
rule=source_bucket.replication.rules[0],
)
|