def test_retention_policy_no_lock(bucket, capsys):
    storage_set_retention_policy.set_retention_policy(bucket.name,
                                                      RETENTION_POLICY)
    bucket.reload()

    assert bucket.retention_period is RETENTION_POLICY
    assert bucket.retention_policy_effective_time is not None
    assert bucket.retention_policy_locked is None

    storage_get_retention_policy.get_retention_policy(bucket.name)
    out, _ = capsys.readouterr()
    assert "Retention Policy for {}".format(bucket.name) in out
    assert "Retention Period: 5" in out
    assert "Effective Time: " in out
    assert "Retention Policy is locked" not in out

    blob = bucket.blob(BLOB_NAME)
    blob.upload_from_string(BLOB_CONTENT)

    assert blob.retention_expiration_time is not None

    storage_remove_retention_policy.remove_retention_policy(bucket.name)
    bucket.reload()
    assert bucket.retention_period is None

    time.sleep(RETENTION_POLICY)
def test_retention_policy_lock(bucket, capsys):
    storage_set_retention_policy.set_retention_policy(bucket.name,
                                                      RETENTION_POLICY)
    bucket.reload()
    assert bucket.retention_policy_locked is None

    storage_lock_retention_policy.lock_retention_policy(bucket.name)
    bucket.reload()
    assert bucket.retention_policy_locked is True

    storage_get_retention_policy.get_retention_policy(bucket.name)
    out, _ = capsys.readouterr()
    assert "Retention Policy is locked" in out