Skip to content

Commit

Permalink
Merge pull request #47 from edx/ashultz0/is_enabled_api
Browse files Browse the repository at this point in the history
feat: add state of feature toggle to API for general use
  • Loading branch information
ashultz0 committed Sep 2, 2021
2 parents 6c08605 + 4392833 commit 510f3c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Change Log
Unreleased
~~~~~~~~~~

[0.9.0] - 2021-09-01
~~~~~~~~~~~~~~~~~~~~
* Add is verified name enabled to the API
* ADR for the use of signals in name affirmation service

[0.8.2] - 2021-08-31
Expand Down
2 changes: 1 addition & 1 deletion edx_name_affirmation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Django app housing name affirmation logic.
"""

__version__ = '0.8.2'
__version__ = '0.9.0'

default_app_config = 'edx_name_affirmation.apps.EdxNameAffirmationConfig' # pylint: disable=invalid-name
11 changes: 11 additions & 0 deletions edx_name_affirmation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging

from edx_name_affirmation import toggles
from edx_name_affirmation.exceptions import (
VerifiedNameAttemptIdNotGiven,
VerifiedNameDoesNotExist,
Expand All @@ -16,6 +17,16 @@
log = logging.getLogger(__name__)


def is_verified_name_enabled():
"""
For callers without direct toggle import available to ask if the verified name feature is enabled.
Since this uses edx_toggles it expects to be called
while servicing a request and will check the cached results.
"""
return toggles.is_verified_name_enabled()


def create_verified_name(
user, verified_name, profile_name, verification_attempt_id=None,
proctored_exam_attempt_id=None, status=VerifiedNameStatus.PENDING,
Expand Down
10 changes: 10 additions & 0 deletions edx_name_affirmation/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import ddt
from edx_toggles.toggles.testutils import override_waffle_flag

from django.contrib.auth import get_user_model
from django.core.cache import cache
Expand All @@ -13,6 +14,7 @@
create_verified_name_config,
get_verified_name,
get_verified_name_history,
is_verified_name_enabled,
should_use_verified_name_for_certs,
update_verification_attempt_id,
update_verified_name_status
Expand All @@ -25,6 +27,7 @@
)
from edx_name_affirmation.models import VerifiedName, VerifiedNameConfig
from edx_name_affirmation.statuses import VerifiedNameStatus
from edx_name_affirmation.toggles import VERIFIED_NAME_FLAG

User = get_user_model()

Expand Down Expand Up @@ -311,3 +314,10 @@ def test_create_verified_name_config_no_overwrite(self):
create_verified_name_config(self.user, use_verified_name_for_certs=True)
create_verified_name_config(self.user)
self.assertTrue(should_use_verified_name_for_certs(self.user))

def test_is_verified_name_enabled_false(self):
self.assertFalse(is_verified_name_enabled())

@override_waffle_flag(VERIFIED_NAME_FLAG, True)
def test_is_verified_name_enabled_true(self):
self.assertTrue(is_verified_name_enabled())

0 comments on commit 510f3c5

Please sign in to comment.