mypy fixes
This commit is contained in:
@@ -187,7 +187,7 @@ def test_should_get_data(
|
||||
# Arrange
|
||||
object_name, expected_data = data_in_minio
|
||||
# Act
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
# Assert
|
||||
assert received_data is not None
|
||||
assert same_data(expected_data, received_data)
|
||||
@@ -200,7 +200,7 @@ def test_should_get_none_for_nonexistent_object(
|
||||
# Arrange
|
||||
object_name = "nonexistent_object"
|
||||
# Act
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
# Assert
|
||||
assert received_data is None
|
||||
|
||||
@@ -225,7 +225,7 @@ def test_should_raise_connection_error_on_get_when_not_connected(
|
||||
adapter = MinioAdapter() # not connected
|
||||
# Act & Assert
|
||||
with pytest.raises(ConnectionError):
|
||||
adapter._get("some_object") # type: ignore
|
||||
adapter._get("some_object")
|
||||
|
||||
|
||||
def test_should_log_warning_when_getting_nonexistent_object(
|
||||
@@ -291,17 +291,17 @@ def test_should_put_data(
|
||||
"""Test that the MinioAdapter can put data into a bucket."""
|
||||
# Arrange
|
||||
object_name = "new_test_object"
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is None # ensure object does not exist yet
|
||||
# Act
|
||||
minio_adapter._put(object_name, data) # type: ignore
|
||||
minio_adapter._put(object_name, data)
|
||||
# Assert
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is not None
|
||||
assert same_data(data, received_data)
|
||||
# Cleanup
|
||||
bucket_name = str(os.getenv("MINIO_BUCKET"))
|
||||
minio_adapter._client.remove_object(bucket_name, object_name)
|
||||
minio_adapter._client.remove_object(bucket_name, object_name) # type: ignore
|
||||
|
||||
|
||||
def test_should_update_data(
|
||||
@@ -312,13 +312,13 @@ def test_should_update_data(
|
||||
# Arrange
|
||||
object_name, _ = data_in_minio
|
||||
new_data = BytesIO(random.randbytes(2**21)) # 2 MiB
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is not None
|
||||
assert not same_data(received_data, new_data)
|
||||
# Act
|
||||
minio_adapter._put(object_name, new_data) # type: ignore
|
||||
minio_adapter._put(object_name, new_data)
|
||||
# Assert
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is not None
|
||||
assert same_data(new_data, received_data)
|
||||
|
||||
@@ -358,7 +358,7 @@ def test_should_raise_connection_error_on_put_when_not_connected(
|
||||
adapter = MinioAdapter() # not connected
|
||||
# Act & Assert
|
||||
with pytest.raises(ConnectionError):
|
||||
adapter._put("some_object", data) # type: ignore
|
||||
adapter._put("some_object", data)
|
||||
|
||||
|
||||
def test_should_delete_object(
|
||||
@@ -368,12 +368,12 @@ def test_should_delete_object(
|
||||
"""Test that the MinioAdapter can delete an object from a bucket."""
|
||||
# Arrange
|
||||
object_name, _ = data_in_minio
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is not None # ensure object exists
|
||||
# Act
|
||||
minio_adapter._delete(object_name) # type: ignore
|
||||
minio_adapter._delete(object_name)
|
||||
# Assert
|
||||
received_data = minio_adapter._get(object_name) # type: ignore
|
||||
received_data = minio_adapter._get(object_name)
|
||||
assert received_data is None
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ def test_should_raise_connection_error_on_delete_when_not_connected(
|
||||
adapter = MinioAdapter() # not connected
|
||||
# Act & Assert
|
||||
with pytest.raises(ConnectionError):
|
||||
adapter._delete("some_object") # type: ignore
|
||||
adapter._delete("some_object")
|
||||
|
||||
|
||||
def test_should_list_objects(
|
||||
@@ -409,9 +409,9 @@ def test_should_list_objects(
|
||||
object_name, _ = data_in_minio
|
||||
new_data = BytesIO(random.randbytes(2**21)) # 2 MiB
|
||||
new_data_name = "another_test_object"
|
||||
minio_adapter._put(new_data_name, new_data) # type: ignore
|
||||
minio_adapter._put(new_data_name, new_data)
|
||||
# Act
|
||||
objects = minio_adapter._list_objects() # type: ignore
|
||||
objects = minio_adapter._list_objects()
|
||||
# Assert
|
||||
assert isinstance(objects, list)
|
||||
assert len(objects) == 2
|
||||
@@ -428,10 +428,10 @@ def test_should_list_objects_with_prefix(
|
||||
object_name, _ = data_in_minio
|
||||
new_data = BytesIO(random.randbytes(2**21)) # 2 MiB
|
||||
new_data_name = "prefix_test_object"
|
||||
minio_adapter._put(new_data_name, new_data) # type: ignore
|
||||
minio_adapter._put(new_data_name, new_data)
|
||||
prefix = "prefix_"
|
||||
# Act
|
||||
objects = minio_adapter._list_objects(prefix) # type: ignore
|
||||
objects = minio_adapter._list_objects(prefix)
|
||||
# Assert
|
||||
assert isinstance(objects, list)
|
||||
assert len(objects) == 1
|
||||
@@ -459,7 +459,7 @@ def test_should_raise_connection_error_on_list_objects_when_not_connected(
|
||||
adapter = MinioAdapter() # not connected
|
||||
# Act & Assert
|
||||
with pytest.raises(ConnectionError):
|
||||
adapter._list_objects() # type: ignore
|
||||
adapter._list_objects()
|
||||
|
||||
|
||||
# allows local debugging by running file as script
|
||||
|
||||
Reference in New Issue
Block a user