2022-03-15 19:51:03 +00:00
|
|
|
import pytest
|
|
|
|
from botocore.exceptions import ClientError
|
|
|
|
|
2022-10-04 16:28:30 +00:00
|
|
|
from . import fixture_efs # noqa # pylint: disable=unused-import
|
2022-03-15 19:51:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_describe_filesystem_config__unknown(efs):
|
|
|
|
with pytest.raises(ClientError) as exc_info:
|
|
|
|
efs.describe_lifecycle_configuration(FileSystemId="unknown")
|
|
|
|
err = exc_info.value.response["Error"]
|
2023-07-05 22:47:50 +00:00
|
|
|
assert err["Code"] == "FileSystemNotFound"
|
|
|
|
assert err["Message"] == "File system 'unknown' does not exist."
|
2022-03-15 19:51:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_describe_filesystem_config__initial(efs):
|
|
|
|
create_fs_resp = efs.create_file_system(CreationToken="foobar")
|
|
|
|
fs_id = create_fs_resp["FileSystemId"]
|
|
|
|
|
|
|
|
resp = efs.describe_lifecycle_configuration(FileSystemId=fs_id)
|
2023-07-05 22:47:50 +00:00
|
|
|
assert resp["LifecyclePolicies"] == []
|
2022-03-15 19:51:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_put_lifecycle_configuration(efs):
|
|
|
|
# Create the file system.
|
|
|
|
create_fs_resp = efs.create_file_system(CreationToken="foobar")
|
|
|
|
create_fs_resp.pop("ResponseMetadata")
|
|
|
|
fs_id = create_fs_resp["FileSystemId"]
|
|
|
|
|
|
|
|
# Create the lifecycle configuration
|
|
|
|
resp = efs.put_lifecycle_configuration(
|
|
|
|
FileSystemId=fs_id, LifecyclePolicies=[{"TransitionToIA": "AFTER_30_DAYS"}]
|
|
|
|
)
|
2023-07-05 22:47:50 +00:00
|
|
|
assert len(resp["LifecyclePolicies"]) == 1
|
|
|
|
assert resp["LifecyclePolicies"][0] == {"TransitionToIA": "AFTER_30_DAYS"}
|
2022-03-15 19:51:03 +00:00
|
|
|
|
|
|
|
# Describe the lifecycle configuration
|
|
|
|
resp = efs.describe_lifecycle_configuration(FileSystemId=fs_id)
|
2023-07-05 22:47:50 +00:00
|
|
|
assert len(resp["LifecyclePolicies"]) == 1
|
|
|
|
assert resp["LifecyclePolicies"][0] == {"TransitionToIA": "AFTER_30_DAYS"}
|