test refac
This commit is contained in:
parent
213e41198a
commit
b1d844a638
@ -1,33 +1,31 @@
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from pyinfra.storage.adapters.azure import AzureStorageAdapter
|
||||
from pyinfra.storage.clients.azure import get_azure_client
|
||||
from pyinfra.storage.storage import Storage
|
||||
from pyinfra.storage.storages import get_azure_storage
|
||||
from pyinfra.test.storage.adapter_mock import StorageAdapterMock
|
||||
from pyinfra.test.storage.client_mock import StorageClientMock
|
||||
|
||||
|
||||
@pytest.mark.parametrize("client_name", ["mock", "azure"])
|
||||
def test_purging_bucket_yields_empty_bucket(storage, bucket_name):
|
||||
storage.purge(bucket_name)
|
||||
data_received = storage.get_all(bucket_name)
|
||||
assert not {*data_received}
|
||||
class TestStorage:
|
||||
def test_purging_bucket_yields_empty_bucket(self, storage, bucket_name):
|
||||
storage.purge(bucket_name)
|
||||
data_received = storage.get_all(bucket_name)
|
||||
assert not {*data_received}
|
||||
|
||||
def test_getting_object_put_in_bucket_is_object(self, storage, bucket_name):
|
||||
storage.put(bucket_name, "file", b"content")
|
||||
data_received = storage.get(bucket_name, "file")
|
||||
assert b"content" == data_received
|
||||
|
||||
@pytest.mark.parametrize("client_name", ["mock", "azure"])
|
||||
def test_getting_object_put_in_bucket_is_object(storage, bucket_name):
|
||||
storage.put(bucket_name, "file", b"content")
|
||||
data_received = storage.get(bucket_name, "file")
|
||||
assert b"content" == data_received
|
||||
|
||||
|
||||
@pytest.mark.parametrize("client_name", ["mock", "azure"])
|
||||
def test_getting_objects_put_in_bucket_are_objects(storage, bucket_name):
|
||||
storage.put(bucket_name, "file1", b"content 1")
|
||||
storage.put(bucket_name, "file2", b"content 2")
|
||||
data_received = storage.get_all(bucket_name)
|
||||
assert {b"content 1", b"content 2"} == {*data_received}
|
||||
def test_getting_objects_put_in_bucket_are_objects(self, storage, bucket_name):
|
||||
storage.put(bucket_name, "file1", b"content 1")
|
||||
storage.put(bucket_name, "file2", b"content 2")
|
||||
data_received = storage.get_all(bucket_name)
|
||||
assert {b"content 1", b"content 2"} == {*data_received}
|
||||
|
||||
|
||||
def get_adapter(client_name):
|
||||
@ -47,12 +45,5 @@ def adapter(client_name):
|
||||
def storage(client_name, bucket_name):
|
||||
storage = Storage(get_adapter(client_name))
|
||||
storage.purge(bucket_name)
|
||||
logging.info(client_name)
|
||||
return storage
|
||||
|
||||
|
||||
# @pytest.mark.parametrize("client_name", ["mock", "azure"])
|
||||
# def test_storages(adapter):
|
||||
# storage_tester.test_purging_bucket_yields_empty_bucket()
|
||||
# storage_tester.test_getting_objects_put_in_bucket_are_objects()
|
||||
# storage_tester.test_getting_object_put_in_bucket_is_object()
|
||||
# assert True
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user