forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azure service admin controls for automatic voiceover (oppia#21453)
* Adds admin controls for Azure config * Fixes mypy checks * Updates variable name * Fixes backend tests
- Loading branch information
Showing
14 changed files
with
450 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
from core.domain import topic_fetchers | ||
from core.domain import topic_services | ||
from core.domain import user_services | ||
from core.domain import voiceover_services | ||
from core.domain import wipeout_service | ||
from core.platform import models | ||
from core.platform.auth import firebase_auth_services | ||
|
@@ -62,13 +63,15 @@ | |
from mypy_imports import exp_models | ||
from mypy_imports import opportunity_models | ||
from mypy_imports import user_models | ||
from mypy_imports import voiceover_models | ||
|
||
( | ||
audit_models, blog_models, exp_models, opportunity_models, | ||
user_models | ||
user_models, voiceover_models | ||
) = models.Registry.import_models([ | ||
models.Names.AUDIT, models.Names.BLOG, models.Names.EXPLORATION, | ||
models.Names.OPPORTUNITY, models.Names.USER | ||
models.Names.OPPORTUNITY, models.Names.USER, | ||
models.Names.VOICEOVER | ||
]) | ||
|
||
BOTH_MODERATOR_AND_ADMIN_EMAIL = '[email protected]' | ||
|
@@ -1499,7 +1502,7 @@ def test_raises_error_if_not_question_admin_or_question_submitter_(# pylint: dis | |
|
||
|
||
class GenerateDummyTranslationOpportunitiesTest(test_utils.GenericTestBase): | ||
"""Checks the conditions for generation of dummy translation | ||
"""Checks the conditions for generation of dummy translation | ||
opportunities.""" | ||
|
||
def setUp(self) -> None: | ||
|
@@ -1548,7 +1551,7 @@ def test_handler_raises_error_with_non_int_num_dummy_translation_opportunities_t | |
response = self.post_json( | ||
'/adminhandler', { | ||
'action': 'generate_dummy_translation_opportunities', | ||
'num_dummy_translation_opportunities_to_generate': | ||
'num_dummy_translation_opportunities_to_generate': | ||
'invalid_type' | ||
}, csrf_token=csrf_token, expected_status_int=400) | ||
|
||
|
@@ -3367,3 +3370,71 @@ def test_handler_with_without_exploration_id_in_payload_raise_error(self) -> Non | |
'At \'http://localhost/interactions\' these errors are happening:\n' | ||
'Missing key in handler args: exp_id.' | ||
) | ||
|
||
|
||
class AutomaticVoiceoverAdminControlHandlerTests(test_utils.GenericTestBase): | ||
"""Tests for admin config for automatic voiceovers.""" | ||
|
||
def setUp(self) -> None: | ||
super().setUp() | ||
self.signup(self.CURRICULUM_ADMIN_EMAIL, 'testsuper') | ||
self.voiceover_autogeneration_policy_model = ( | ||
voiceover_models.VoiceoverAutogenerationPolicyModel( | ||
id=voiceover_models.VOICEOVER_AUTOGENERATION_POLICY_ID) | ||
) | ||
self.voiceover_autogeneration_policy_model.language_codes_mapping = {} | ||
( | ||
self.voiceover_autogeneration_policy_model. | ||
autogenerated_voiceovers_are_enabled | ||
) = True | ||
self.voiceover_autogeneration_policy_model.update_timestamps() | ||
self.voiceover_autogeneration_policy_model.put() | ||
|
||
def test_handler_should_be_able_to_return_azure_config(self) -> None: | ||
response = self.get_json( | ||
'/automatic_voiceover_admin_control_handler', | ||
expected_status_int=200) | ||
self.assertTrue( | ||
response['autogenerated_voiceovers_are_enabled']) | ||
|
||
def test_admin_should_be_able_to_update_config(self) -> None: | ||
self.login(self.CURRICULUM_ADMIN_EMAIL, is_super_admin=True) | ||
csrf_token = self.get_new_csrf_token() | ||
|
||
voiceover_services.update_admin_config_for_voiceover_autogeneration( | ||
False) | ||
self.assertFalse( | ||
voiceover_services. | ||
is_voiceover_autogeneration_using_cloud_service_enabled() | ||
) | ||
|
||
self.post_json( | ||
'/automatic_voiceover_admin_control_handler', { | ||
'autogenerated_voiceovers_are_enabled': True | ||
}, csrf_token=csrf_token) | ||
|
||
self.assertTrue( | ||
voiceover_services. | ||
is_voiceover_autogeneration_using_cloud_service_enabled() | ||
) | ||
self.logout() | ||
|
||
def test_non_admin_should_not_be_able_to_update_config(self) -> None: | ||
csrf_token = self.get_new_csrf_token() | ||
|
||
voiceover_services.update_admin_config_for_voiceover_autogeneration( | ||
False) | ||
self.assertFalse( | ||
voiceover_services. | ||
is_voiceover_autogeneration_using_cloud_service_enabled() | ||
) | ||
|
||
self.post_json( | ||
'/automatic_voiceover_admin_control_handler', { | ||
'autogenerated_voiceovers_are_enabled': 'true' | ||
}, csrf_token=csrf_token, expected_status_int=400) | ||
|
||
self.assertFalse( | ||
voiceover_services. | ||
is_voiceover_autogeneration_using_cloud_service_enabled() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.