From 33dd6083c7b3e1671229afc952b972362fbf03df Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 31 Dec 2020 14:27:04 +0100 Subject: [PATCH] rename available_suffixes_more_info -> get_available_suffixes --- app/api/views/alias_options.py | 6 +++--- app/dashboard/views/custom_alias.py | 4 ++-- app/oauth/views/authorize.py | 4 ++-- tests/dashboard/test_custom_alias.py | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/api/views/alias_options.py b/app/api/views/alias_options.py index f6ad5301..d8a96599 100644 --- a/app/api/views/alias_options.py +++ b/app/api/views/alias_options.py @@ -4,7 +4,7 @@ from sqlalchemy import desc from app.api.base import api_bp, require_api_auth from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX from app.dashboard.views.custom_alias import ( - available_suffixes_more_info, + get_available_suffixes, ) from app.extensions import db from app.log import LOG @@ -301,7 +301,7 @@ def options_v4(): domain_name = convert_to_id(domain_name) ret["prefix_suggestion"] = domain_name - suffixes = available_suffixes_more_info(user) + suffixes = get_available_suffixes(user) # custom domain should be put first ret["suffixes"] = list([suffix.suffix, suffix.signed_suffix] for suffix in suffixes) @@ -372,7 +372,7 @@ def options_v5(): domain_name = convert_to_id(domain_name) ret["prefix_suggestion"] = domain_name - suffixes = available_suffixes_more_info(user) + suffixes = get_available_suffixes(user) # custom domain should be put first ret["suffixes"] = [ diff --git a/app/dashboard/views/custom_alias.py b/app/dashboard/views/custom_alias.py index a69293e7..0ee94649 100644 --- a/app/dashboard/views/custom_alias.py +++ b/app/dashboard/views/custom_alias.py @@ -40,7 +40,7 @@ class SuffixInfo: is_premium: bool -def available_suffixes_more_info(user: User) -> [SuffixInfo]: +def get_available_suffixes(user: User) -> [SuffixInfo]: """ Similar to as available_suffixes() but also return whether the suffix comes from a premium domain Note that is-premium-domain is only relevant for SL domain @@ -98,7 +98,7 @@ def custom_alias(): return redirect(url_for("dashboard.index")) user_custom_domains = [cd.domain for cd in current_user.verified_custom_domains()] - suffixes = available_suffixes_more_info(current_user) + suffixes = get_available_suffixes(current_user) at_least_a_premium_domain = False for suffix in suffixes: if not suffix.is_custom and suffix.is_premium: diff --git a/app/oauth/views/authorize.py b/app/oauth/views/authorize.py index 610e38e3..8ac244bc 100644 --- a/app/oauth/views/authorize.py +++ b/app/oauth/views/authorize.py @@ -7,7 +7,7 @@ from itsdangerous import SignatureExpired from app.alias_utils import check_alias_prefix from app.config import EMAIL_DOMAIN -from app.dashboard.views.custom_alias import signer, available_suffixes_more_info +from app.dashboard.views.custom_alias import signer, get_available_suffixes from app.extensions import db from app.jose_utils import make_id_token from app.log import LOG @@ -112,7 +112,7 @@ def authorize(): user_custom_domains = [ cd.domain for cd in current_user.verified_custom_domains() ] - suffixes = available_suffixes_more_info(current_user) + suffixes = get_available_suffixes(current_user) return render_template( "oauth/authorize.html", diff --git a/tests/dashboard/test_custom_alias.py b/tests/dashboard/test_custom_alias.py index 48e05790..062c892e 100644 --- a/tests/dashboard/test_custom_alias.py +++ b/tests/dashboard/test_custom_alias.py @@ -5,7 +5,7 @@ from app.config import EMAIL_DOMAIN from app.dashboard.views.custom_alias import ( signer, verify_prefix_suffix, - available_suffixes_more_info, + get_available_suffixes, ) from app.extensions import db from app.models import ( @@ -108,10 +108,10 @@ def test_available_suffixes(flask_client): CustomDomain.create(user_id=user.id, domain="test.com", verified=True) - assert len(available_suffixes_more_info(user)) > 0 + assert len(get_available_suffixes(user)) > 0 # first suffix is custom domain - first_suffix = available_suffixes_more_info(user)[0] + first_suffix = get_available_suffixes(user)[0] assert first_suffix.is_custom assert first_suffix.suffix == "@test.com" assert first_suffix.signed_suffix.startswith("@test.com") @@ -126,12 +126,12 @@ def test_available_suffixes_default_domain(flask_client): user.default_alias_public_domain_id = sl_domain.id # first suffix is SL Domain - first_suffix = available_suffixes_more_info(user)[0] + first_suffix = get_available_suffixes(user)[0] assert first_suffix.suffix.endswith(f"@{sl_domain.domain}") user.default_alias_public_domain_id = None # first suffix is custom domain - first_suffix = available_suffixes_more_info(user)[0] + first_suffix = get_available_suffixes(user)[0] assert first_suffix.suffix == "@test.com"