def test_enable_versioning(self, runway_context: MockRunwayContext) -> None: """Test enable_versioning.""" stubber = runway_context.add_stubber("s3") bucket = Bucket(runway_context, "test-bucket") stubber.add_response( "get_bucket_versioning", {"Status": "Suspended", "MFADelete": "Enabled"}, {"Bucket": "test-bucket"}, ) stubber.add_response( "put_bucket_versioning", {}, { "Bucket": "test-bucket", "VersioningConfiguration": { "Status": "Enabled", "MFADelete": "Enabled", }, }, ) with stubber: bucket.enable_versioning() stubber.assert_no_pending_responses()
def test_enable_versioning_skipped( self, caplog: LogCaptureFixture, runway_context: MockRunwayContext ) -> None: """Test enable_versioning with Status=Enabled.""" caplog.set_level(logging.DEBUG, logger="runway.core.providers.aws.s3.bucket") stubber = runway_context.add_stubber("s3") bucket = Bucket(runway_context, "test-bucket") stubber.add_response( "get_bucket_versioning", {"Status": "Enabled"}, {"Bucket": "test-bucket"} ) with stubber: bucket.enable_versioning() stubber.assert_no_pending_responses() assert ( 'did not modify versioning policy for bucket "test-bucket"; already enabled' ) in caplog.messages