def test_describe_mount_targets_no_id_given(efs): with pytest.raises(ClientError) as exc_info: efs.describe_mount_targets() resp = exc_info.value.response assert has_status_code(resp, 400) assert "BadRequest" in resp["Error"]["Message"]
def test_describe_mount_targets_invalid_file_system_id(efs): with pytest.raises(ClientError) as exc_info: efs.describe_mount_targets(FileSystemId="fs-12343289") resp = exc_info.value.response assert has_status_code(resp, 404) assert "FileSystemNotFound" in resp["Error"]["Message"]
def test_describe_mount_targets_invalid_mount_target_id(efs): with pytest.raises(ClientError) as exc_info: efs.describe_mount_targets(MountTargetId="fsmt-ad9f8987") resp = exc_info.value.response assert has_status_code(resp, 404) assert "MountTargetNotFound" in resp["Error"]["Message"]
def test_delete_file_system_invalid_file_system_id(efs): with pytest.raises(ClientError) as exc_info: efs.delete_file_system(FileSystemId="fs-2394287") resp = exc_info.value.response assert has_status_code(resp, 404) assert "FileSystemNotFound" in resp["Error"]["Message"]
def test_describe_mount_targets_paging(efs, ec2, file_system): fs_id = file_system["FileSystemId"] # Get a list of subnets. subnet_list = ec2.describe_subnets()["Subnets"] # Create several mount targets. for subnet in subnet_list: efs.create_mount_target(FileSystemId=fs_id, SubnetId=subnet["SubnetId"]) # First call (Start) # ------------------ # Call the tested function resp1 = efs.describe_mount_targets(FileSystemId=fs_id, MaxItems=2) # Check the response status assert has_status_code(resp1, 200) # Check content of the result. resp1.pop("ResponseMetadata") assert set(resp1.keys()) == {"NextMarker", "MountTargets"} assert len(resp1["MountTargets"]) == 2 mt_id_set_1 = {mt["MountTargetId"] for mt in resp1["MountTargets"]} # Second call (Middle) # -------------------- # Get the next marker. resp2 = efs.describe_mount_targets(FileSystemId=fs_id, MaxItems=2, Marker=resp1["NextMarker"]) # Check the response status resp2_metadata = resp2.pop("ResponseMetadata") assert resp2_metadata["HTTPStatusCode"] == 200 # Check the response contents. assert set(resp2.keys()) == {"NextMarker", "MountTargets", "Marker"} assert len(resp2["MountTargets"]) == 2 assert resp2["Marker"] == resp1["NextMarker"] mt_id_set_2 = {mt["MountTargetId"] for mt in resp2["MountTargets"]} assert mt_id_set_1 & mt_id_set_2 == set() # Third call (End) # ---------------- # Get the last marker results resp3 = efs.describe_mount_targets(FileSystemId=fs_id, MaxItems=20, Marker=resp2["NextMarker"]) # Check the response status resp3_metadata = resp3.pop("ResponseMetadata") assert resp3_metadata["HTTPStatusCode"] == 200 # Check the response contents. assert set(resp3.keys()) == {"MountTargets", "Marker"} assert resp3["Marker"] == resp2["NextMarker"] mt_id_set_3 = {mt["MountTargetId"] for mt in resp3["MountTargets"]} assert mt_id_set_3 & (mt_id_set_1 | mt_id_set_2) == set()
def test_describe_file_systems_invalid_creation_token(efs): resp = efs.describe_file_systems(CreationToken="fizzle") assert has_status_code(resp, 200) assert len(resp["FileSystems"]) == 0
def test_describe_file_systems_invalid_marker(efs): with pytest.raises(ClientError) as exc_info: efs.describe_file_systems(Marker="fiddlesticks") resp = exc_info.value.response assert has_status_code(resp, 400) assert "BadRequest" in resp["Error"]["Message"]
def test_delete_mount_target_invalid_mount_target_id(efs): with pytest.raises(ClientError) as exc_info: efs.delete_mount_target(MountTargetId="fsmt-98487aef0a7") resp = exc_info.value.response assert has_status_code(resp, 404) assert "MountTargetNotFound" == resp["Error"]["Code"]
def test_create_mount_target_invalid_file_system_id(efs, subnet): with pytest.raises(ClientError) as exc_info: efs.create_mount_target(FileSystemId="fs-12343289", SubnetId=subnet["SubnetId"]) resp = exc_info.value.response assert has_status_code(resp, 404) assert "FileSystemNotFound" == resp["Error"]["Code"]
def test_describe_file_systems_invalid_file_system_id(efs): with pytest.raises(ClientError) as exc_info: efs.describe_file_systems(FileSystemId="fs-29879313") resp = exc_info.value.response assert has_status_code(resp, 404) assert "FileSystemNotFound" == resp["Error"]["Code"]